Page 1 of 1
Copy latest backup, delete old backup

Posted:
Tue Jun 27, 2023 1:38 pm
by bayon
I have a piece of medical software that creates nightly backups, but the backsups have gotten so big that it is introducing some new problems in the way we used to manage things, so I am redoing everything.
What I would like to do is have Hazel copy the latest nightly backup to a folder on the desktop, and our backup software will only grab that folder. I also need Hazel to delete whatever backup was in that folder the night before, leaving me with one backup at any given time. The backups file that the software produces is a different name each time.
Currently I have a rule that is set to Date Added is Today, copy to Backups folder. This appears to be working well. What's the best rule to safely purge that folder of any old today and only leave the latest backup?
Re: Copy latest backup, delete old backup

Posted:
Wed Jun 28, 2023 10:59 am
by Mr_Noodle
You can try "Date added is not among the X most recent" to match everything but the X most recent backups.
Re: Copy latest backup, delete old backup

Posted:
Wed Jun 28, 2023 1:19 pm
by bayon
Thank you, I will give that a shot.
Re: Copy latest backup, delete old backup

Posted:
Fri May 03, 2024 1:18 am
by pubay
Apologies for reviving an old post. I am trying to do something similar to the OP. A backup of a certain programme is created in a dedicated folder twice a day, and I would like the backups (which take the form of folders) older than two days to be automatically deleted. Initially I tried using “Date added is not in the last 2 days” to delete the older backups, but nothing happened. I then tried "Date added is not among the X most recent", but again nothing happens. How can I get this to work?
Re: Copy latest backup, delete old backup

Posted:
Fri May 03, 2024 12:28 pm
by Mr_Noodle
Can you go through the troubleshooting guide here? Post your results as well as the rule you are using.
Re: Copy latest backup, delete old backup

Posted:
Fri May 03, 2024 4:07 pm
by pubay
I checked the Rule Preview and Rule Status, and everything seems to be in order. I also checked the log, and it says “matched” for everything. I'm afraid I can't figure out how to post a rule to this forum.
Re: Copy latest backup, delete old backup

Posted:
Mon May 06, 2024 11:12 am
by Mr_Noodle
You need to host the images on another site. If you don't already have a cloud service of your own that you use, you can use imgur.com.
Re: Copy latest backup, delete old backup

Posted:
Mon May 06, 2024 3:56 pm
by pubay
Re: Copy latest backup, delete old backup

Posted:
Tue May 07, 2024 11:15 am
by Mr_Noodle
Can you post the preview, rule status and logs?
Re: Copy latest backup, delete old backup

Posted:
Tue May 07, 2024 4:27 pm
by pubay
Re: Copy latest backup, delete old backup

Posted:
Wed May 08, 2024 12:06 pm
by Mr_Noodle
It looks like everything is matching "Top Rule". I don't know what that rule does but it won't reach the "Delete..." rule. You need to either tweak the conditions for "Top Rule" or re-order the rules.
Re: Copy latest backup, delete old backup

Posted:
Wed May 08, 2024 4:01 pm
by pubay
The Top Rule is to “run rules on folder contents.” I was under the impression that one needed such a rule, but I tried disabling it and running the “Delete…” rule, and it worked. Does this mean that a top rule such as mine is unnecessary? My other rules have the same Top Rule and seem to work.
Re: Copy latest backup, delete old backup

Posted:
Thu May 09, 2024 8:31 am
by Mr_Noodle
Problem is probably that you have that rule matching all folders, including the ones you want to match the second rule. Do you really want Hazel to go into subfolders in this case? If you do, then as mentioned before, you need to tweak the conditions or reorder the rules.
Re: Copy latest backup, delete old backup

Posted:
Thu May 09, 2024 3:41 pm
by pubay
I think I understand, and in this case the Top Rule would seem to be unnecessary for what I want the rule to do. Thank you for your help.