Remove directory script


Recommended Posts

Every day at 03:00, Kodi runs a backup and saves the folder to an unRAID server. yyyymmdd0300 is the name, with the date changing for every new backup. I just deleted 201605260300, leaving 201605270300 as the only directory. Currently, I'm just opening a PuTTY window and running 'rm -rf dirname' every morning. It's about 5gb and ~70,000 files, so Windows take a LONG time to delete across the network when using Total Commander.

 

I'd like to automate this process, taking great care to leave today's backup but deleting the yesterday's files.

 

Saving location: mnt/user/Backup but I should probably make it's own share so nothing else goes there. I've looked at a few scripts, but they haven't accounted for a dir name that changes. At least the scripts I've found...

Link to comment

Back when I used Kodi/XBMC I used an add-on that handled backing up the library to a share on my server for me. It had options to set how many backup copies you wanted to keep and it would delete anything older above that set threshold automatically. I don't remember exactly what the name was but I found it in the built in list of available add-one.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.