|
|
|
07-25-2021, 01:08 PM
|
#1
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Backup Limit pack - Keep x number of most recent timestamped backups
This script pack replaces my "amagalma_Keep x number of most recent timestamped backups of current project file (deletes older ones - no undo!).lua" script that was in ReaPack and is the solution of limiting backup files till there is a native solution.
It consists of three scripts (all have "- Keep x number of most recent timestamped backups of current project file" as a suffix):
- amagalma_Backup Limit Manual
- amagalma_Backup Limit Automatic
- Backup Limit Settings
The Manual version of the script (1) performs a manual cleanup according to the settings. It has the following features:
- Automatically takes care of backup files created in the current project directory and in the additional directory if set (both with absolute or relative path)
- Works for both saved or unsaved ("untitled") projects
- Supports all timestamp formats (both with seconds precision or not)
- Has two different modes, according to the settings (keep_one_file_per_date or not)
- Can be combined with the Save action (40026) into a custom action, so that it tides things up each time you save
The Automatic version (2) is a "set and forget" version of the manual version of the script.
- A few moments after a backup file is created, it runs automatically the manual version.
- It is as light on CPU as it can be!
- Can be set on a toolbar if you like, or you can set it as a startup action.
With the Settings script (3) you can set how many backup files you want to keep (default backup limit = 5) and choose if you want the keep_one_file_per_date mode enabled (default = no).
keep_one_file_per_date mode, if enabled, is useful if you do not want to delete all backups earlier than the backup limit that you have set, so that you can return to the state that your project had in a past date.
Example of keep_one_file_per_date mode:
Let's say your current project is test.rpp and you have these backups:
Quote:
test-2021-07-20_1235.rpp-bak
test-2021-07-20_1230.rpp-bak
test-2021-07-20_1225.rpp-bak
test-2021-07-19_2300.rpp-bak
test-2021-07-19_2255.rpp-bak
test-2021-07-19_2250.rpp-bak
test-2021-07-18_1610.rpp-bak
test-2021-07-18_1605.rpp-bak
|
If you tell it to keep only 2 backups it will do this:
Quote:
test-2021-07-20_1235.rpp-bak (1st to keep)
test-2021-07-20_1230.rpp-bak (2nd to keep)
test-2021-07-20_1225.rpp-bak (deleted)
test-2021-07-19_2300.rpp-bak (keeps it: most recent on a different date)
test-2021-07-19_2255.rpp-bak (deleted: same date)
test-2021-07-19_2250.rpp-bak (deleted: same date)
test-2021-07-18_1610.rpp-bak (keeps it: most recent on a different date)
test-2021-07-18_1605.rpp-bak (deleted: same date)
|
Stand-Alone version:
amagalma_Backup Limit Stand-Alone - Keep x number of most recent timestamped backups of the selected project(s) (browse to specify)
This is a stand-alone version of the amagalma_Backup Limit Manual script. Instead of working with the current project, you can browse and specify one or more projects.
It performs a manual cleanup according to the settings. It has the following features:
- You can specify any number of projects
- Automatically takes care of backup files created in the current project directory and in the additional directory if set (both with absolute or relative path)
- Supports all timestamp formats (both with seconds precision or not)
- You can specify how many backups you want to keep (default backup limit = 5)
- "Keep one file per different date" setting, if enabled, will keep one backup per different date that is earier than the backup limit that you have set, so that you can return to the state that your project had in a past date (default = enabled).
Script pack in Reapack
Last edited by amagalma; 02-02-2022 at 04:25 AM.
|
|
|
07-25-2021, 01:55 PM
|
#2
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
Sweet. Do we run the automatic one in project startup actions ?
|
|
|
07-25-2021, 02:37 PM
|
#3
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Yes, if you wish. Or you can enable it and disable it whenever you like.
|
|
|
07-25-2021, 04:09 PM
|
#4
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
Do these deferred scripts have any serious impact on Reaper CPU or stability?
|
|
|
07-25-2021, 09:48 PM
|
#5
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
Nice approach, amagalma!
On the same subject, I also just released a script which works as replacement of project save:
- Script: X-Raym_Save project and keep only X backups.lua
More info on the dedicated thread!
|
|
|
07-26-2021, 12:58 PM
|
#6
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by Coachz
Do these deferred scripts have any serious impact on Reaper CPU or stability?
|
No impact at all I would say. The deferred script works like this:
It gets once from your Reaper Preferences the time interval you have set for the automatic backups.
Then it just counts time. One second after the interval you have set it runs the manual backup script (only if you are not recording) and resets the timer. Can't be any simpler than this!
|
|
|
07-26-2021, 01:00 PM
|
#7
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by X-Raym
Nice approach, amagalma!
On the same subject, I also just released a script which works as replacement of project save:
- Script: X-Raym_Save project and keep only X backups.lua
More info on the dedicated thread!
|
Thanks X-Raym! Well done to you too!
I believe that our scripts will press the Devs to implement the feature natively sooner
|
|
|
07-29-2021, 05:04 AM
|
#8
|
Human being with feelings
Join Date: Nov 2014
Location: Can Tho - Viet Nam
Posts: 305
|
I don't understand why I can't load and use these scripts
|
|
|
07-29-2021, 09:03 AM
|
#9
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
More info on what is the problem?..
|
|
|
07-30-2021, 07:44 AM
|
#10
|
Human being with feelings
Join Date: Nov 2010
Posts: 1,722
|
I've just run this script on save and it deleted all backups from all dates except the last 5 with the current date. Bit scary!
I have the settings as per the attached file.
Any ideas where the problem is?
What does it use for date checking? The "date created" by the system? Or the date in the actual backup file name?
Last edited by mozart999uk; 07-30-2021 at 07:51 AM.
Reason: typo
|
|
|
07-30-2021, 08:21 AM
|
#11
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
Quote:
Originally Posted by mozart999uk
I've just run this script on save and it deleted all backups from all dates except the last 5 with the current date. Bit scary!
I have the settings as per the attached file.
Any ideas where the problem is?
What does it use for date checking? The "date created" by the system? Or the date in the actual backup file name?
|
It's not scary at all if you have backups
|
|
|
07-30-2021, 01:28 PM
|
#12
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by mozart999uk
I've just run this script on save and it deleted all backups from all dates except the last 5 with the current date. Bit scary!
I have the settings as per the attached file.
Any ideas where the problem is?
What does it use for date checking? The "date created" by the system? Or the date in the actual backup file name?
|
The date in the actual backup file name in the current version. (the older script used to look at the "date created" by the system)
Could you try with another project? Make a copy of your backup files, take a screenshot and then run again the script. If it didn't work, post the screenshot. (and you can place back again the copied backup files, so you can try again after I find out why it did not work for you)
Silly error by me in the code: I wrote == 1 instead of == "1"
Fixed in v1.02
Sorry about that!
Last edited by amagalma; 07-30-2021 at 01:45 PM.
|
|
|
08-02-2021, 12:44 AM
|
#13
|
Human being with feelings
Join Date: Nov 2010
Posts: 1,722
|
Quote:
Originally Posted by amagalma
The date in the actual backup file name in the current version. (the older script used to look at the "date created" by the system)
Could you try with another project? Make a copy of your backup files, take a screenshot and then run again the script. If it didn't work, post the screenshot. (and you can place back again the copied backup files, so you can try again after I find out why it did not work for you)
Silly error by me in the code: I wrote == 1 instead of == "1"
Fixed in v1.02
Sorry about that!
|
Thanks :-)
|
|
|
08-03-2021, 03:54 AM
|
#14
|
Human being with feelings
Join Date: Nov 2010
Posts: 1,722
|
Can I just check if this is right?
I've attached a pic.
This is after just doing a save and running the script. I've got it set to "10" backups and "keep 1 per date".
For some reason there's 6 backups from yesterday remaining rather than just 1.....
|
|
|
08-03-2021, 05:10 AM
|
#15
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
First, it keeps the number you have set. So, the 10 most recent ones, regardless of their date.
After that, it goes into the logic of one per date.
|
|
|
08-03-2021, 05:16 AM
|
#16
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
It should have deleted the 08-02_1556 though...
|
|
|
08-03-2021, 05:54 AM
|
#17
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
How come we are not using modified date? Seems like the most logical thing and avoids dealing with files names
|
|
|
08-03-2021, 06:23 AM
|
#18
|
Human being with feelings
Join Date: Nov 2010
Posts: 1,722
|
Quote:
Originally Posted by amagalma
First, it keeps the number you have set. So, the 10 most recent ones, regardless of their date.
After that, it goes into the logic of one per date.
|
Ah ha! Great. That makes sense. Thanks for explaining :-)
|
|
|
08-03-2021, 06:45 AM
|
#19
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by Coachz
How come we are not using modified date? Seems like the most logical thing and avoids dealing with files names
|
Getting the date from the file name is faster, needs no additional API dependencies.
Example: Each person has a name and an ID which holds his birthday info. If my name was my birthday date, would you need to look at my ID to see when is birthday?
|
|
|
08-09-2021, 05:59 PM
|
#20
|
Human being with feelings
Join Date: Nov 2014
Location: Can Tho - Viet Nam
Posts: 305
|
Quote:
Originally Posted by X-Raym
Nice approach, amagalma!
On the same subject, I also just released a script which works as replacement of project save:
- Script: X-Raym_Save project and keep only X backups.lua
More info on the dedicated thread!
|
I don't understand why I can't run it
|
|
|
08-10-2021, 01:00 AM
|
#21
|
Human being with feelings
Join Date: Nov 2010
Posts: 1,722
|
Quote:
Originally Posted by lachinhan
I don't understand why I can't run it
|
I'd post this on Xrays dedicated thread and see if he can help you :-)
|
|
|
08-17-2021, 04:43 AM
|
#22
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
Amagalma,
How hard would this be to add please?
Backups to keep
------------------------
Today x
Previous days y
Num previous days to keep z
Thanks for your consideration and have a great day !
|
|
|
08-18-2021, 01:56 AM
|
#23
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
I am working on something else this period plus the script logic is good for my needs as it is at the moment...
If you really need it to work like this, then I could make a paid customized version for you.
Thanks
|
|
|
08-18-2021, 04:27 AM
|
#24
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,770
|
No worries. I just thought this feature request would be a very practical way to manage backups that most users would like including me. Maybe I'll look at the code and see if I can modify it. Thanks for all the help.
|
|
|
09-06-2021, 12:08 PM
|
#25
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
How can I make it save backups to folder backup in project folder?
I have selected Save to additional directory in Preferences -> Project
|
|
|
09-23-2021, 12:28 AM
|
#26
|
Human being with feelings
Join Date: Jun 2020
Posts: 656
|
Hi, I don't know when but your scripts (and X-Raym's) stopped working (for me)
out of nowhere it doesn't delete anything how could I troubleshoot this? I tried reinstalling but nope. I didn't change anything on my backup settings. It used to work beautifully :'(
https://i.imgur.com/fV5BN7S.mp4
R 6.36 Mojave OS
|
|
|
09-23-2021, 01:28 AM
|
#27
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
I really like the automatic version, thanks amagalma!
Given that my FR https://forum.cockos.com/showthread.php?t=255831 probably won't make it into Reaper anytime soon, I am wondering if you might be willing to integrate a similar option into your script (and if other users would appreciate and use it too)?
Basically I think it could work like this:
- If project directory does not exist, ignore following steps..
- If project directory does exist, check for a subfolder called "Backups" (or other name specified by user) and create it if not present
- From now on, every backup Reaper creates is automatically moved to that subfolder as soon as the script checks the backups.
- The script now counts the backups in the subfolder and deletes the oldest one once there are more than x backups.
I think this would help everyone to keep the project directory more organized while still having the possibility to backup unsaved projects to an additional directory.
Even better (for me) would be if the script could also move all backups from the additional directory to the project directory backups subfolder once the project is saved, and delete every further backup Reaper creates in the additional directory. But I am aware that this might be a bit convoluted and too specific for my own use case.
|
|
|
09-23-2021, 04:44 AM
|
#28
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Quote:
Originally Posted by Phazma
I really like the automatic version, thanks amagalma!
Given that my FR https://forum.cockos.com/showthread.php?t=255831 probably won't make it into Reaper anytime soon, I am wondering if you might be willing to integrate a similar option into your script (and if other users would appreciate and use it too)?
Basically I think it could work like this:
- If project directory does not exist, ignore following steps..
- If project directory does exist, check for a subfolder called "Backups" (or other name specified by user) and create it if not present
- From now on, every backup Reaper creates is automatically moved to that subfolder as soon as the script checks the backups.
- The script now counts the backups in the subfolder and deletes the oldest one once there are more than x backups.
I think this would help everyone to keep the project directory more organized while still having the possibility to backup unsaved projects to an additional directory.
|
YES! +1
|
|
|
09-23-2021, 04:20 PM
|
#29
|
Human being with feelings
Join Date: Jan 2012
Posts: 1,180
|
Quote:
Originally Posted by tonalstates
Hi, I don't know when but your scripts (and X-Raym's) stopped working (for me)
out of nowhere it doesn't delete anything how could I troubleshoot this? I tried reinstalling but nope. I didn't change anything on my backup settings. It used to work beautifully :'(
https://i.imgur.com/fV5BN7S.mp4
R 6.36 Mojave OS
|
Still working here (I'm using the manual version of the script set as a custom action combined with save or save as.. )
reaper 6.36, High Sierra
|
|
|
09-24-2021, 02:18 PM
|
#30
|
Human being with feelings
Join Date: Jun 2020
Posts: 656
|
Quote:
Originally Posted by Triode
Still working here (I'm using the manual version of the script set as a custom action combined with save or save as.. )
|
Same, I have it that way too but idkw it just stopped doing it's thing And I'm no coder so I'm as prepared as a rock to troubleshoot it
|
|
|
12-07-2021, 08:44 AM
|
#31
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Hi amagalma,
I noticed too that the script doesn't work properly anymore and my folders are full of backups again (macOS 10.13.6).
Not sure if this has anything to do with it but I have set a relative path for backups, just named to " Backups". So if the project is unsaved Reaper saves backups into a subfolder called " Backups" inside the default recording path and if the project is saved Reaper save backups also to a subfolder called " Backups" but inside the project directory. Both backup folders (for saved and unsaved) seem to contain more backups than what is set in the Backup Limit Settings script.
Using the automatic version btw.
Last edited by Phazma; 12-07-2021 at 08:49 AM.
|
|
|
12-09-2021, 07:16 AM
|
#32
|
Human being with feelings
Join Date: Aug 2011
Posts: 517
|
Same problem as Phazma here
|
|
|
12-14-2021, 03:04 AM
|
#33
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Guys having trouble with the script, are you all on OSX? Do both versions of the script (automatic and manual) NOT work? Or only the automatic one? Since which version of Reaper did it stop working? Thanks!
|
|
|
12-14-2021, 03:07 AM
|
#34
|
Human being with feelings
Join Date: Jan 2012
Posts: 1,180
|
I use the manual one combined with "save" and "save as.."
It still works for me. I'm on OSX High Sierra, Reaper v6.40
|
|
|
12-14-2021, 03:13 AM
|
#35
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
@Triode: does the automatic one work for you?
|
|
|
12-14-2021, 04:48 AM
|
#36
|
Human being with feelings
Join Date: Jan 2012
Posts: 1,180
|
Amagalma: The automatic one doesn't seem to work here. I have two projects open though. Is it meant to be able to handle two open projects?
|
|
|
12-15-2021, 02:28 AM
|
#37
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Quote:
Originally Posted by amagalma
Guys having trouble with the script, are you all on OSX? Do both versions of the script (automatic and manual) NOT work? Or only the automatic one? Since which version of Reaper did it stop working? Thanks!
|
- OSX High Sierra
- Both versions do not work
- It works in no Reaper version anymore (even tried v6.32 and v6.33 which were directly before and after your script release -> doesn't work)
Not sure what has happened or changed because I recall that it DID work when I first tried it months ago.
|
|
|
12-15-2021, 05:01 AM
|
#38
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by Triode
Amagalma: The automatic one doesn't seem to work here. I have two projects open though. Is it meant to be able to handle two open projects?
|
It works on the active project (chosen project tab).
Quote:
Originally Posted by Phazma
- OSX High Sierra
- Both versions do not work
- It works in no Reaper version anymore (even tried v6.32 and v6.33 which were directly before and after your script release -> doesn't work)
Not sure what has happened or changed because I recall that it DID work when I first tried it months ago.
|
So, something with OSX might have changed, or the backups could be at a path that is either inaccessible or read-only..
Could you all having issues try this test script and post the results?:
Test limit backups.lua
Thanks!
|
|
|
12-15-2021, 11:30 AM
|
#39
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
On saved project:
Code:
Project is saved.
projpath = /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript
proj_filename = Backup Testscript
saveopts 8
in_add_dir = /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript/Backups
Number of backups found in in_add_dir_backups : 0
Failed to create TEST FILE TO DELETE at : /Volumes/Macintosh SSD/Reaper/Backup Script Test/Backup Testscript/Backups
~~ End of Test ~~
On unsaved project:
Code:
Project is unsaved.
in_add_dir = /Users/mirko/Library/Application Support/REAPER/ Reaper Media/Backups
Number of backups found in in_add_dir_backups : 0
Failed to create TEST FILE TO DELETE at : /Users/mirko/Library/Application Support/REAPER/ Reaper Media/Backups
~~ End of Test ~~
|
|
|
12-15-2021, 04:22 PM
|
#40
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Ok, so it seems that it cannot create nor delete a file at these paths. Could they be read-only? Or could it be that Reaper for some reason doesn't have enough privilege to create and delete files? Are you on an administrator user account?
Last edited by amagalma; 12-15-2021 at 04:37 PM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:51 PM.
|