Copy latest backup, delete old backup

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Copy latest backup, delete old backup 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?
bayon
 
Posts: 18
Joined: Sun Oct 09, 2016 9:42 pm

Re: Copy latest backup, delete old backup 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.
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Copy latest backup, delete old backup Wed Jun 28, 2023 1:19 pm • by bayon
Thank you, I will give that a shot.
bayon
 
Posts: 18
Joined: Sun Oct 09, 2016 9:42 pm

Re: Copy latest backup, delete old backup 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?
pubay
 
Posts: 5
Joined: Thu May 02, 2024 1:28 am

Re: Copy latest backup, delete old backup 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.
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Copy latest backup, delete old backup 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.
pubay
 
Posts: 5
Joined: Thu May 02, 2024 1:28 am

Re: Copy latest backup, delete old backup 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.
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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

Re: Copy latest backup, delete old backup Tue May 07, 2024 11:15 am • by Mr_Noodle
Can you post the preview, rule status and logs?
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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

Re: Copy latest backup, delete old backup 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.
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Copy latest backup, delete old backup 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.
pubay
 
Posts: 5
Joined: Thu May 02, 2024 1:28 am

Re: Copy latest backup, delete old backup 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.
Mr_Noodle
Site Admin
 
Posts: 11272
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support