<div dir="ltr"><div class="gmail_default" style="font-size:small">Good advice to "test with caution" ; ) !!<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 18, 2021 at 7:04 PM Andrew Randrianasulu via Cin <<a href="mailto:cin@lists.cinelerra-gg.org">cin@lists.cinelerra-gg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">В сообщении от Monday 18 January 2021 13:43:36 Rafa Mar Multimedia en Gnu\Linux via Cin написал(а):<br>
> Thank you very much Reuss András, with the multiple backup copies you have<br>
> done an excellent job, perhaps you could limit these so that you do not end<br>
> up with thousands of copies, with about 50 would be enough.<br>
<br>
<br>
I tried to copy/paste cleanup function, TEST WITH CAUTION!!!!<br>
<br>
======<br>
void MWindow::clean_backups()<br>
{<br>
FileSystem fs;<br>
int total_excess;<br>
long oldest = 0;<br>
int oldest_item = -1;<br>
int result;<br>
char string[BCTEXTLEN];<br>
<br>
// Delete extra backups<br>
fs.set_filter("backup_*.xml");<br>
fs.complete_path(preferences->index_directory);<br>
fs.update(preferences->index_directory);<br>
<br>
total_excess = fs.dir_list.total - preferences->index_count;<br>
printf("Total excess of backups: %i \n", total_excess);<br>
<br>
//printf("MWindow::clean_backups 1 %d\n", fs.dir_list.total);<br>
<br>
while(total_excess > 0)<br>
{<br>
// Get oldest<br>
for(int i = 0; i < fs.dir_list.total; i++)<br>
{<br>
fs.join_names(string, preferences->index_directory, fs.dir_list[i]->name);<br>
<br>
if(i == 0 || fs.get_date(string) <= oldest)<br>
{<br>
oldest = fs.get_date(string);<br>
oldest_item = i;<br>
}<br>
}<br>
<br>
if(oldest_item >= 0)<br>
{<br>
// Remove backup file<br>
fs.join_names(string,<br>
preferences->index_directory,<br>
fs.dir_list[oldest_item]->name);<br>
//printf("MWindow::clean_backups 1 %s\n", string);<br>
if(remove(string))<br>
perror("delete_backups");<br>
delete fs.dir_list[oldest_item];<br>
fs.dir_list.remove_number(oldest_item);<br>
<br>
}<br>
<br>
total_excess--;<br>
}<br>
}<br>
<br>
<br>
=====<br>
<br>
it clears backups down to same number as max indexes number set in Preferences,<br>
looking for backup_*.xml (note "_" part!!!)<br>
<br>
you need to add <br>
<br>
diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h<br>
index 8f9bfbb7..df9fd9db 100644<br>
--- a/cinelerra-5.1/cinelerra/mwindow.h<br>
+++ b/cinelerra-5.1/cinelerra/mwindow.h<br>
@@ -853,6 +853,7 @@ public:<br>
int get_cpus();<br>
//<br>
void clean_indexes();<br>
+ void clean_backups();<br>
// TimeBomb timebomb;<br>
SigHandler *sighandler;<br>
int restart_status;<br>
<br>
also ...<br>
<br>
Ha, remaint of Timebomb :}<br>
<br>
Need to be deleted ....<br>
<br>
*My* hack for making many_backups was in mwindow.C:<br>
<br>
@@ -4276,10 +4369,27 @@ void MWindow::save_backup()<br>
edl->optimize();<br>
edl->set_path(session->filename);<br>
<br>
- char backup_path[BCTEXTLEN], backup_path1[BCTEXTLEN];<br>
+ char backup_path[BCTEXTLEN], backup_path1[BCTEXTLEN], backup_path2[BCTEXTLEN];<br>
+<br>
+ time_t t = time(NULL);<br>
+ struct tm tm = *localtime(&t);<br>
+ char BACKUP_FILE2[BCTEXTLEN] ;<br>
+ sprintf(BACKUP_FILE2, _("backup_%02d%02d%02d-%02d%02d%02d.xml"),<br>
+ tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,<br>
+ tm.tm_hour, tm.tm_min, tm.tm_sec);<br>
+<br>
+ snprintf(backup_path2, sizeof(backup_path2), "%s/%s",<br>
+ File::get_config_path(), BACKUP_FILE2);<br>
+<br>
snprintf(backup_path1, sizeof(backup_path1), "%s/%s",<br>
File::get_config_path(), BACKUP_FILE1);<br>
get_backup_path(backup_path, sizeof(backup_path));<br>
+<br>
+ char cmd[1024], *cp = cmd;<br>
+ cp += sprintf(cp, "cp %s %s &", backup_path, backup_path2);<br>
+ system(cmd);<br>
+<br>
+<br>
rename(backup_path, backup_path1);<br>
edl->save_xml(&file, backup_path);<br>
file.terminate_string();<br>
<br>
For Reuss' solution you most likely need to tweak <br>
<br>
fs.set_filter("backup_*.xml"); <br>
<br>
line<br>
<br>
....<br>
<br>
<br>
<br>
-- <br>
Cin mailing list<br>
<a href="mailto:Cin@lists.cinelerra-gg.org" target="_blank">Cin@lists.cinelerra-gg.org</a><br>
<a href="https://lists.cinelerra-gg.org/mailman/listinfo/cin" rel="noreferrer" target="_blank">https://lists.cinelerra-gg.org/mailman/listinfo/cin</a><br>
</blockquote></div>