Request for assistance - - - saving files

73 views
Skip to first unread message

o1bigtenor

unread,
Nov 19, 2020, 6:46:40 AM11/19/20
to Ledger
Greetings

I am mostly a ham fisted operator when I'm working with the innards of linux.
So I was trying to set up a symlink and managed to rm my ledger.dat file.
The backup was at least 70 if not a lot more hours of work ago.
rm is a very efficient file removal tool so I did waste some time on
trying to recover the file but
not too much. So to the question!

So I took that last backup to my ledger.dat file but now, being
properly totally paranoid, I want to save said file in at least 3
discrete locations. I use a raid-10 array for most of my long term
storage needs so getting to individual files there can easily take me
some 8 to even 10 levels of directories. I've looked at the parallel
command but it seems to be quite a bit more for a parallel input(s) to
parallel output(s) kind of thing. Found some reference to symlink
chains but no real examples of such. Thought of trying to roll
something in bash but my multi-level deep folders system put the
brakes on that idea in a hurry.

Does anyone here have any ideas, or has already implemented, on how to
save something from a text editor to multiple locations
simultaneously? (Please)

TIA

Vikas Rawal

unread,
Nov 19, 2020, 6:57:13 AM11/19/20
to ledge...@googlegroups.com
rsync and cron is not sufficient?

Vikas

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/CAPpdf5_gt4vbR4CTazbk_STCv_OTJUrmufuh8FMNS699Q3KTZg%40mail.gmail.com.

Boyd Kelly

unread,
Nov 19, 2020, 7:00:46 AM11/19/20
to ledge...@googlegroups.com
Store your ledger.dat in a private git repository (gitlab or github) and do a commit and push every transaction.   Then you don't really even need a backup.



--

Eric S Fraga

unread,
Nov 19, 2020, 7:25:50 AM11/19/20
to ledge...@googlegroups.com
TL;DR: I use a combination of git (as Boyd has suggested, committing
changes every transaction) and rsync to back up to a different device.

Longer version: there are 2 different issues here:

1. micro-management of information, e.g. changes and reasons for those
changes
2. keeping back ups in case of hardware/software/user failure (e.g. rm)

Different tools are appropriate for each of these but both of these
issues are important in their own right.

For 1, version (or revision) control systems are ideal. There are many,
including git, mercurial, subversion, src, rcs, ... Each of these has
their respective advantages and disadvantages and personal taste often
is the deciding factor. I use src for single file revision control and
git for projects. They do not provide more than simple backup but do
provide the ability to roll back changes and an audit trail.

For 2, I would avoid the use of symlinks and instead ensure you have a
proper more general backup procedure. For instance, I rsync my whole
disc to a different computer in a different site frequently (hourly
often but at least once a day in any case) during the day and I do full
scheduled backups onto detachable drives periodically (weekly or monthly
depending on how I feel).

--
Eric S Fraga via Emacs 28.0.50 & org 9.4 on Debian bullseye/sid

o1bigtenor

unread,
Nov 19, 2020, 10:35:47 AM11/19/20
to Ledger
On Thu, Nov 19, 2020 at 5:57 AM Vikas Rawal <vikas...@gmail.com> wrote:
>
> rsync and cron is not sufficient?
>
Hmmm - - - -you seem to have missed the comment "ham fisted operator . . .
inards of LInux" - - - grin!

Haven't yet had the occasion to dabble in this level of the 'black arts'.
See later response as well.

Thanks for the ideas!

o1bigtenor

unread,
Nov 19, 2020, 10:38:18 AM11/19/20
to Ledger
On Thu, Nov 19, 2020 at 6:00 AM Boyd Kelly <bke...@coastsystems.net> wrote:
>
> Store your ledger.dat in a private git repository (gitlab or github) and do a commit and push every transaction. Then you don't really even need a backup.
>

Sorry - - - - but my financial information doesn't leave my fingers unless I'm
forced to concede that movement.
It may not be accurate but working with the bulk of my information being
'out there' - - - - sorry - - - - the security angle would just produce far too
much stress.

Thanks for the idea - - - maybe I need to run my own git server?

Thanks!!!!!!

o1bigtenor

unread,
Nov 19, 2020, 10:49:40 AM11/19/20
to Ledger
On Thu, Nov 19, 2020 at 6:25 AM Eric S Fraga <e.f...@ucl.ac.uk> wrote:
>
> TL;DR: I use a combination of git (as Boyd has suggested, committing
> changes every transaction) and rsync to back up to a different device.

The 'TL;DR' brought a smile to my face. A friend and mentor often replied
to short questions with 2 to 5 page emails and he used sure regularly!
Sadly - - - - he died this May and boy do I miss his thinking - - - he called
himself a computer dinosaur but his breadth of knowledge - - - - scary!
>
> Longer version: there are 2 different issues here:
>
> 1. micro-management of information, e.g. changes and reasons for those
> changes
> 2. keeping back ups in case of hardware/software/user failure (e.g. rm)
>
> Different tools are appropriate for each of these but both of these
> issues are important in their own right.
>
> For 1, version (or revision) control systems are ideal. There are many,
> including git, mercurial, subversion, src, rcs, ... Each of these has
> their respective advantages and disadvantages and personal taste often
> is the deciding factor. I use src for single file revision control and
> git for projects. They do not provide more than simple backup but do
> provide the ability to roll back changes and an audit trail.
>
> For 2, I would avoid the use of symlinks and instead ensure you have a
> proper more general backup procedure. For instance, I rsync my whole
> disc to a different computer in a different site frequently (hourly
> often but at least once a day in any case) during the day and I do full
> scheduled backups onto detachable drives periodically (weekly or monthly
> depending on how I feel).
>

I have long had the habit of backing up what I'm working on every 5 minutes.
When I can I set this up in the software as an automated function. This kind
of function just isn't in text editors so I do the manual saving. IN this way I
do NOT have to fiddle fart with the system whining that I'm trying to overwrite
the file, which I think I am actually doing, and the updated version is just
'saved'.

What I would like is that file ledgerxxxxxxx.dat that I'm working on would
be updated when I'm saving but not only to the one location but rather to
2 or 3 or 4 (how ever many I want) locations all at the same time, without
having to argue with the system that I'm overwriting a file.

The idea is NOT to save the file as a unique entity every number of minutes
in each of a number of locations but rather to have one 'complete' file in each
of x number of locations be updated simultaneously and easily. So far I'm
not finding anything that's even remotely straight forward.

From what I understand - - - using rsync would spawn a plethora of versions
meaning that I would have to create a timestamp on each to differentiate.
Maybe, at least from my perspective, not the 'simplest' creation.

The ideas presented are useful - - - but I'm hoping to find something just
somewhat different (begging posture assumed - - - grin!).

Regards

Eric S Fraga

unread,
Nov 19, 2020, 11:34:08 AM11/19/20
to ledge...@googlegroups.com
On Thursday, 19 Nov 2020 at 09:49, o1bigtenor wrote:
> The 'TL;DR' brought a smile to my face.

;-)

> This kind of function just isn't in text editors

Well, this isn't quite true. Emacs will create backup files when you
edit one and you can ask Emacs to create new backups every time you save
the file. These backup files will be numbered and you can specify how
many such backups to keep. But using Emacs may not be what you would
like to do...

o1bigtenor

unread,
Nov 19, 2020, 1:31:39 PM11/19/20
to Ledger
On Thu, Nov 19, 2020 at 10:34 AM Eric S Fraga <e.f...@ucl.ac.uk> wrote:
>
> On Thursday, 19 Nov 2020 at 09:49, o1bigtenor wrote:
> > The 'TL;DR' brought a smile to my face.
>
> ;-)
>
> > This kind of function just isn't in text editors
>
> Well, this isn't quite true. Emacs will create backup files when you
> edit one and you can ask Emacs to create new backups every time you save
> the file. These backup files will be numbered and you can specify how
> many such backups to keep. But using Emacs may not be what you would
> like to do...
>
When I first started using linux vi was recommended.
'm sorta comfortable with it but need a cheat sheet - - - a LOT!

Tried emacs - - - - my mentor suggested not to but it was his go
to - - - - boy was I out in the weeds and it seemed everything I tried
made it more difficult.
Today I use geany as an editor - - - its not for a purist but its handy
and I love the search function. (just have not been able to get that working
in either of vi nor emacs which is one reason why emacs got pitched!)

So - - - I'd bet this procedure in emacs is hard coded - - -yes?

Sigh - - - - still back to looking for unobtanium I think.

Thanks!

Fergus Cameron

unread,
Nov 19, 2020, 8:30:09 PM11/19/20
to ledge...@googlegroups.com
On 19/11/2020, o1bigtenor <o1big...@gmail.com> wrote:
> I am mostly a ham fisted operator when I'm working with the innards of
> linux.
> So I was trying to set up a symlink and managed to rm my ledger.dat file.
> The backup was at least 70 if not a lot more hours of work ago.
> rm is a very efficient file removal tool so I did waste some time on
> trying to recover the file but
> not too much. So to the question!

This is usually possible but terribly involved. That's a lot to
loose. Happens to us all now and again, I guess.

> So I took that last backup to my ledger.dat file but now, being
> properly totally paranoid, I want to save said file in at least 3
> discrete locations. I use a raid-10 array for most of my long term
> storage needs so getting to individual files there can easily take me
> some 8 to even 10 levels of directories. I've looked at the parallel
> command but it seems to be quite a bit more for a parallel input(s) to
> parallel output(s) kind of thing. Found some reference to symlink
> chains but no real examples of such. Thought of trying to roll
> something in bash but my multi-level deep folders system put the
> brakes on that idea in a hurry.
>
> Does anyone here have any ideas, or has already implemented, on how to
> save something from a text editor to multiple locations
> simultaneously? (Please)

This is really intrinsic to your workflow (and other aspects of your
data storage and lifecycle) but you can be confident of finding a good
answer with standard tools.

'rsync' (or 'cpdup') is probably the correct tool here; neither make
multiple copies but simply copy if it has changed, you can also tell
them 'no delete' if you're worried about them replicating your 'rm'
too quickly. If you wanted to integrate that with editing feature you
could, of course, use 'cron' to periodically copy whatever was on the
disk or inotify tools to copy every time you wrote to the file. If
you're in and out the editor enough, a simple function that did ['cp'
or 'tar' after exiting] might also be adequate (see below for VERY
rough example). If your editor does backup copies that might also add
to your confidence (i.e. grab the working directory and get the copies
and the current file).

'git' is an option (the idea that you must push to the cloud is
incorrect) you can simply have a local repository and commit, HOWEVER,
it is not a great backup option IMHO. I would, however, recommend
using 'git' in addition to your auto-save requirements.

--
['cp' after exiting]: #1
# define a function that will be imported to our shell and thus
executable from command line
editor()
{
ledger=$1
ledger_file=`basename $ledger`
/path/to/real-editor "$ledger"
cp "$ledger" `mktemp -u "/safe/location/$ledger_file.XXXXX"`
}

Claudine Chionh

unread,
Nov 19, 2020, 10:04:14 PM11/19/20
to ledge...@googlegroups.com
It's no trouble just managing your ledger directory under git on your personal machine, without pushing it to github, gitlab, or any other remote repository. At least this way, you don't lose your history. You could even use something like gitwatch [1] to commit whenever you save changes.

[1] https://github.com/gitwatch/gitwatch

--
Claudine Chionh (she/her)
Melbourne, Australia
https://www.claudinec.net/

Fergus Cameron

unread,
Nov 19, 2020, 10:37:47 PM11/19/20
to ledge...@googlegroups.com
... feel I should probably qualify all that, saying, I just email myself my ledger; I don't deliver it to multiple systems but that's 'cause I already have a strategy for backing up my email

Kushal Kumaran

unread,
Nov 20, 2020, 12:03:11 AM11/20/20
to ledge...@googlegroups.com
Perhaps the Save Actions plugin mentioned on
https://wiki.geany.org/config/all_you_never_wanted_to_know_about_file_saving
will be of use to you.

--
regards,
kushal

Eric S Fraga

unread,
Nov 20, 2020, 8:45:41 AM11/20/20
to ledge...@googlegroups.com
On Thursday, 19 Nov 2020 at 12:30, o1bigtenor wrote:
> So - - - I'd bet this procedure in emacs is hard coded - - -yes?

Not quite sure what you mean about hard code. In Emacs, other than the
very small core of code written in C, the code is written in Lisp and
totally user accessible, meaning that almost all the functionality can
be modified by the user (although needing to know Lisp etc., of
course). This is actually what makes Emacs incredibly powerful and
adaptable. But also what, to some (to all?), makes it difficult, having
a very steep learning curve.

o1bigtenor

unread,
Nov 20, 2020, 9:26:21 AM11/20/20
to Ledger
On Fri, Nov 20, 2020 at 7:45 AM Eric S Fraga <e.f...@ucl.ac.uk> wrote:
>
> On Thursday, 19 Nov 2020 at 12:30, o1bigtenor wrote:
> > So - - - I'd bet this procedure in emacs is hard coded - - -yes?
>
> Not quite sure what you mean about hard code. In Emacs, other than the
> very small core of code written in C, the code is written in Lisp and
> totally user accessible, meaning that almost all the functionality can
> be modified by the user (although needing to know Lisp etc., of
> course). This is actually what makes Emacs incredibly powerful and
> adaptable. But also what, to some (to all?), makes it difficult, having
> a very steep learning curve.
>
>

Hmmmmmmmm - - - - interesting that you call a vertical line a curve - - - -yes?

I have tried to use emacs and found that I could not find a reasonable search
tool , at least one that I could find AND use and so that dropped emacs from
my use list. I'm not trying to deprecate emacs - - - - I've been told
that I does
have EVERYTHING (including the kitchen sink) but the same person, himself
an aficionado, suggested I not pursue its use.

Sorry for mis-stating that particular bit of code provenance.

Regards

Daniele Nicolodi

unread,
Nov 20, 2020, 9:52:17 AM11/20/20
to ledge...@googlegroups.com
On 20/11/2020 15:25, o1bigtenor wrote:

> I have tried to use emacs and found that I could not find a reasonable search
> tool , at least one that I could find AND use and so that dropped emacs from
> my use list.

Do you mean you could not find _one_ search tool but you found several
extremely powerful tools and you were overwhelmed by the capability of
Emacs? :-) Saying that Emacs does not have a reasonable search tool is
akin to say that the ocean does not have enough water (or Lisp does not
have enough parentheses, to keep the metaphor on the subject).

> I'm not trying to deprecate emacs - - - - I've been told
> that I does
> have EVERYTHING (including the kitchen sink) but the same person, himself
> an aficionado, suggested I not pursue its use.

Without knowing the reasoning that culminated in that advice it is
difficult to say if it was a wise suggestion.

Learning Emacs is an excellent investment if you foresee spending a
significant amount of time editing text and getting into activities or
which your productivity and satisfaction depend on how fast you can
morph bytes in a file to conform to an idea in your head through your
fingers. If that is not the case, maybe, the time spent learning to use
the tool would not have a positive return.

Other reasons for learning Emacs are Org and Magit, but these may solve
problems that even a more restricted set of person has (incidentally a
set that is mostly a subset of the former).

Cheers,
Dan

Robin H. Johnson

unread,
Nov 20, 2020, 8:27:00 PM11/20/20
to ledge...@googlegroups.com
On Thu, Nov 19, 2020 at 05:46:00AM -0600, o1bigtenor wrote:
> Does anyone here have any ideas, or has already implemented, on how to
> save something from a text editor to multiple locations
> simultaneously? (Please)
I feel you need to think outside of the editor. That way you're also not
forced to switch your productive working environment.

Tools such as incron [1] permit automatic actions when some file is
changed. If you combined that with version control, you can have it
commit & optionally push on every change. The action MUST be smart about
the file having not changed since it was last saved.

In this case, run a script, using this incrontab configuration (this
should be a single line, in case your mail clients break it):
```
/home/user/ledger/ IN_CLOSE_WRITE,IN_MOVED_TO,dotdirs=false,recursive=true /home/user/bin/commit-ledger $@/$#
```

Every time a file under /home/user/ledger/ is written or a file is moved
into that same directory, the script will be called, with the full path
to that file as an argument. It won't fire on any files added under
dot-prefixes directories like /home/user/ledger/.git/

Example content for /home/user/bin/commit-ledger, untested:
```
#!/bin/bash
# Assumption: /home/user/ledger/ is a git repo that is initialized
cd /home/user/ledger/
pwd=$(pwd)
abspath=$1

# Remove the leading path
relpath=${abspath#${pwd}}

# Explicitly check if changed:
# git-status will generate output if the file is changed
# 'grep -sq .' will have exit code 1 if NO output is present.
git status --porcelain "${relpath}" |grep -sq . || exit 0

# Commit it:
git commit -q -m "Automated commit: $relpath" "${relpath}"

# Optional:
#git push ...

```

I personally wouldn't push on every commit, but instead have a cronjob
that tries to push to multiple locations (local directory on alternate
media, other servers) every 5 minutes. If there are no changes between
the remote side and the local side, it won't do anything.


[1] https://github.com/ar-/incron

--
Robin Hugh Johnson
Gentoo Linux: Dev, Infra Lead, Foundation Treasurer
E-Mail : rob...@gentoo.org
GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85
GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136
signature.asc

Eric S Fraga

unread,
Nov 23, 2020, 8:06:41 AM11/23/20
to ledge...@googlegroups.com
On Friday, 20 Nov 2020 at 08:25, o1bigtenor wrote:
> Hmmmmmmmm -- -- interesting that you call a vertical line a curve --
> --yes?

as a mathematician, a vertical line does indeed come under the
designation of curve... ;-)
Reply all
Reply to author
Forward
0 new messages