# Suggeston for Location of Backup Files

LO makes it backup files in one directory. It would be nice if it would make backup files in the directory in which the original file is located.

Is this possible?

edit retag close merge delete

1

Or better I think would be relative to the location of the current file, like in distributed ./Backups/ folders, e.g. ~/project1/Backups/, ~/project2/Backups/ ... btw the appropriate place for suggestions is not here, but rather in a bug report (as an improvement suggestion). So if you're already working on that please add the link here to the submitted bug report, as I would like to chime in there too. Thanks.

( 2017-03-01 22:26:18 +0200 )edit

Sort by » oldest newest most voted

===== Start Edit =====
See the much more attentive and well researched answer by @Ratslinger. (I have to take this for another reason to consider what value is in trying to contribute to this breathlessly running ticker without any reasonable structure.)
===== End Edit =====

Since the topic should only apply to the specific system (imo) and not to distributed documents, there is no strong reason to avoid relying on user code ("macros") in this case. To make a routine ('Sub') for saving copies of a document or to move/rename already existing copies (in BASIC e.g.) is rather simple. The Sub must then be assigned to an appropriate document event (or a series of Subs to a series of such events). 'Tools' > 'Customize...' > 'Events' is listing the available events.

If you accept the task, and specifically if you include an option to create a (LIFO) stack of backups to a certain depth, please publish your code. I would be interested. A good idea might, however, be to create a folder 'LibObackups' in each folder containing LibO documents. The stack functionality can be achieved then by changing a numeric appendix to the filename. (Simplest: Highest number = youngest backup.)

more

@Lupp Your notation is well received. It is unfortunate items like this get buried so quickly in this forum. It is even more troublesome to see post after post stating "How do I recover my lost file?". A little "PM" goes a long way.

BTW - these macros were also tested and work using AOO.

( 2017-03-02 17:09:58 +0200 )edit
1

And I noticed that my friend @Ratslinger brought up one "strong reason" why macro based backup won't yet work, he wrote, "Base is not included as this presents other challenges." I want a better solution for Base that does not force me to keep re-naming using Save-As which is the only solution we have right now for successive backups as I develop Base applications. e.g. Save As: MyApplication-01.odb; Save As: MyApplication-02.odb; Save As: MyApplication-03.odb, etc.

( 2017-03-02 19:38:13 +0200 )edit
1

In particular, I want something like Access has: A menu item which creates a backup on my command, and allows me to modify the auto-generated place and name before committing the save. I recall back in the early days, when Access did not yet have it, and I thought it was a great improvement when it was added, and I have loved the way they got this right, and it has saved me hundreds of times when things went wrong. It's simple and quick. It's time LO has such a backup I think.

( 2017-03-02 19:47:01 +0200 )edit

Hi

Sorry, this is not possible ... This is an interesting request for enhancement (especially for the problem of identical file names).

Regards

more

You can change the location where LO places backups through Tools | Options | LibreOffice | Paths

Set the location for Backups to be the same as My Documents.

Edit: Of course this then applies to all backup files; if you have files in other than the default save directory the backups won't be in the same location. Thanks pierre-yves samyn for reminding me :-)

more

1

That's one location. I think you cannot "parametrize" it in a way the OQ obviously had in mind. (Except probably by tricks concerning the OS.)

( 2017-03-01 12:26:42 +0200 )edit

I've brought this up a few times in these posts but it is easy enough to get lost in this forum.

There is an old post in another forum containing a macro to save timestamped copies of various documents with a button or toolbar click.

This was expanded upon by @mark_t on this post by adding an automated save function. All code and instructions are in the post.

This set of macros has has two settings made by the user: how often changed documents are saved; where they are saved to. If the user saves the document (normal save procedure) the automated saves are halted until another unsaved change is made. The save event occurs via a headless call to one of the installed macros.

The directory the backup is saved in is a line of code sPathBackupFolder = "YOUR_DIRECTORY" and all copies go there. However there are ways to change this. For example, since the code already creates a directory if the specified one doesn't exist, sPathBackupFolder = "YOUR_DIRECTORY" & oDoc.Title will put a documents' backup in its' own subdirectory:

There are certainly other ways to easily change directory locations.

Did a lot of testing while this was being developed (LO v 5.1.x) and works fine in Windows and Linux. No one tested this for Mac. Today I also re-ran tests using LO v 5.3.0.3 (Linux Mint 18) and had no problems. This testing included simultaneous saving of Draw, Writer and Calc documents. Impress should also work but haven't tested. Base is not included as this presents other challenges.

The biggest down side to all this (my opinion) there is no regulation on the number of backup copies saved. Please post if anyone comes up with a process for it.

Edit 3/2/2017:

The reason Base was excluded is because of the many ways a user can implement it: Embedded, split, split using server, external DB's etc. This is no way states a Base file can not be saved via a macro.

Many users simply use the embedded version of Base. In the Base documentation, Chapter 9 Macros, on page 63 is a macro which can be executed from a toolbar which will save the .odb in the system specified folder. This macro creates sequentially numbered backups (up to X number). Again, a little imagination can easily change where these backups are stored.

It shouldn't be much more difficult to create macros to save other DB situations.

Also, it was good to reference the documentation again. I knew I had seen somewhere the limiting of entries in a folder. I will see about adapting this to the aforementioned macros.

There are tons of ways to do backups and many other tasks in LO that other products may have. The problem is one may have to put a bit of effort into it. It is a small PRICE to pay.

EDIT 3/6/17 :

Well I see this post is ...

more

@Ratslinger, Humm? Looks good, but TimedBackupReplacementMacro.odt won't run for me. This line ..= GetFileName(sDocNameWithFullPath, sSlash) is trying to call LibreOffice Macros & Dialogs.Tools.ModuleControls.GetFileName which has a different parameter signature, i.e: Sub GetFileName(oRefModel as Object, Filternames()) You have some other Libs loaded or any ideas why this won't run.

( 2017-03-10 05:58:44 +0200 )edit

@Ratslinger, 8-) Just answered my own Q above. In the original source you referred to, I found the other auxiliary functions in the code box below the AutomaticBackup Sub (tip, scroll down far into the box), (and also an "Option Explicit" prefix that was left out). Will test again in a moment.

( 2017-03-10 06:30:25 +0200 )edit

@EasyTrieve "Option Explicit" was not left out. It is at the beginning of the other routines in the Automated process.

( 2017-03-10 16:32:00 +0200 )edit

Please see the above answer to get ALL the routines necessary for this AUTOMATED process to work. They are in the referenced expanded version along with the necessary instructions.

( 2017-03-10 16:39:06 +0200 )edit

You might add a note above: Macro in Base documentation Chapter 9 Macros, page 63 reads in part, ...FOR k = 1 TO inMax - 1 TO 1 STEP -1... but should be FOR k = inMax - 1 TO 1 STEP -1. You just can't have more than one TO in a For. :-)

( 2017-03-19 18:12:44 +0200 )edit

Ok, bear with me please, I'm working bath through things with a fine toothed comb. In your TimedBackupReplacementMacro.odt above, your new sort, and delete etc, needs to be within the loop starting with While sBackup(i) <> "". Otherwise the optional components won't be limited. Only the last of several BACKUP's will be limited by your sort. That is the bug I initially found. But understanding this code allowed me a leg up on the bigger backup problem, which I am grateful-to-you for. :-)

( 2017-04-03 04:20:06 +0200 )edit

No. You haven't followed the above answer. It started with the original code - first link in answer. That was added onto (with other routines) & modified for those routines - second link. This answer modified the modified routine of the original. The While.. is part of the original. Just below that & starting with comment "'code inserted here to end of sub in order..." to the end of the sub was the code I added to limit # of saved records. No idea of "bug" you are talking about.

( 2017-04-03 04:46:01 +0200 )edit

The automated routine is meant for copies for Writer(.odt), Calc(.ods), Draw(.odg) and Impress(.odp) files. These are safe types for original documents and others should be created from these.

( 2017-04-03 04:52:08 +0200 )edit

I don't know how to add a link to this message, at least it's not intuitive to me. You can see Bug 68565. Also, I think I'll just save each document with a version number at the end of the name before I make any changes to it. That's probably the best way as I'll have several backups in numerical order. When I decide that a document is finished, I'll just delete all "backups" except for the last one.

more

1