Recent

Author Topic: [SOLVED] Better customization of target for backups?  (Read 1453 times)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 699
    • My games in Pascal
[SOLVED] Better customization of target for backups?
« on: May 28, 2024, 04:49:51 pm »
There are many options to choose from on where and how to make backups of the project files. However, it doesn't seem flexible enough for me. I wonder, maybe I'm missing something?

The problem I'm having is: I have 244 units in my project, all located in "code" subfolder, with multiple subfolders inside. Sometimes it's faster for me to "grep" (use an external tool to search for) a keyword inside, e.g. to know all places where this specific variable/field/method is referenced.

However, as "backup" folder is dropped in every subfolder... I get double results for files I've edited with one version of the file even being obsolete and causing confusion (I'm 100% sure I removed the reference, but I still get it in grep result, open the file and see the old code, takes a few dozens of seconds to figure out it's in backup folder), requiring me to use a script to delete all backup folders from the project, which while not too bad, but is "extra step" that I'd like to avoid.

So, I wonder, if there an alternative to completely disabling "backup" feature? I mean using version control system I can't remember a single time in the last 5 years that I needed to recover a file from backup, so it's not a big loss, but still a loss :)

So what I'd like to do is to have backups in some "predefined" folder, outside of where the code files are, maybe structured/organized in a similar tree to avoid potential filenames conflict (which isn't my case, but I understand that some users might do weird things that aren't strictly forbidden :)). I wonder if it's possible?
« Last Edit: May 31, 2024, 07:54:57 am by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Thaddy

  • Hero Member
  • *****
  • Posts: 14799
  • Censorship about opinions does not belong here.
Re: Better customization of target for backups?
« Reply #1 on: May 29, 2024, 06:25:37 am »
Using grep  --exclude-dir=backup <other options>, maybe?
Grep will skip directories who's name start with backup.
This can be configured inside Lazarus, I believe.

Completely disabling backup is not recommended.

Example:
grep --exclude-dir=backup -nHIirFw -- <word to find >
« Last Edit: May 29, 2024, 06:58:29 am by Thaddy »
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

n7800

  • Full Member
  • ***
  • Posts: 103
Re: Better customization of target for backups?
« Reply #2 on: May 29, 2024, 07:21:49 am »
I indicated one of the options in this issue. In it I provided a method for automatically creating a commit after compiling a project. I don't know if this is suitable for large projects.

But you can specify any script. For example, which simply makes a copy of only some files (*.pas;*.lfm) or performs an incremental copy, etc.

n7800

  • Full Member
  • ***
  • Posts: 103
Re: Better customization of target for backups?
« Reply #3 on: May 29, 2024, 07:47:48 am »
Another option is to use Main menu > Tools > Configure External Tools. In it we can configure calling any executable file or script using a hotkey. This will allow you to make backups only when you want, and not every compilation.

Since I started using git, I stopped making backups. So I have a lot of hot ones configured for it (status/log/commit).

Plus, it only requires IDE setup, and works for any project with git.

n7800

  • Full Member
  • ***
  • Posts: 103
Re: Better customization of target for backups?
« Reply #4 on: May 29, 2024, 08:47:31 am »
By the way, in the backup settings (in your screenshot) you can simply select the “User defined extensions” option, then the backup files will at least have a different extension ("*.bak"). Then, when searching for files by mask, you will exclude them.

And I wonder why you use "grep" instead of Main menu > Search > Find in files? It provides file search by mask (default is "*.pas;*.pp;*.inc;*.lpr"), supports regular expressions. In the search results window, you can click the desired line to instantly open the file in the editor.

Thaddy

  • Hero Member
  • *****
  • Posts: 14799
  • Censorship about opinions does not belong here.
Re: Better customization of target for backups?
« Reply #5 on: May 29, 2024, 10:02:42 am »
And I wonder why you use "grep" instead of Main menu > Search > Find in files? It provides file search by mask (default is "*.pas;*.pp;*.inc;*.lpr"), supports regular expressions. In the search results window, you can click the desired line to instantly open the file in the editor.
afaik find in files uses grep....
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

n7800

  • Full Member
  • ***
  • Posts: 103
Re: Better customization of target for backups?
« Reply #6 on: May 29, 2024, 10:16:40 am »
afaik find in files uses grep....

Using external utilities for such a needed function would not be a good solution for a cross-platform IDE.

So you can see that it does the search itself in the searchfrm.pas unit (and other).

Eugene Loza

  • Hero Member
  • *****
  • Posts: 699
    • My games in Pascal
Re: Better customization of target for backups?
« Reply #7 on: May 31, 2024, 07:54:46 am »
Sorry for the delay and huge thank you for answers!

Quote
grep --exclude-dir=backup

I don't use grep literally :) FAR under Windows and CatFish under Linux. To my knowledge neither of those have "exclude" option. And even if they have it defeats the simplicity cause :) Might as well just run the script to delete all "backup" folders.

Quote
you can simply select the “User defined extensions” option

Was my first idea, but I usually search in *.* files, to include lpr and inc too.

Quote
make backups only when you want

If I want to make backups manually, then I don't need a backup system :). It's the idea to keep a simplicity of Lazarus backup - as a possible safeguard to recover something I've accidentally screwed up.

Quote
And I wonder why you use "grep" instead of Main menu > Search > Find in files?

Oh, and that's the solution I most likely was looking for. I simply didn't know it exists. Just tested it, had to spend some time to set it up to work as I expect it, but it works and seems to solve the problem perfectly! Thank you!
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

 

TinyPortal © 2005-2018