linux - Script for selectively deleting directories by date -


i'm running sh script on debian machine. it's done nightly , uses rsync create incremental backups. saves each backup in directories named date. have:

2015-07-01 2015-07-02 2015-07-03 2015-07-04 , so-forth 

what able delete old copies list grows. preferably i'd keep daily backups past week, , weekly backups long have space.

which means need 2 things:

  1. check date of each folder name. if date not saturday, , older 7 days, delete it.
  2. check amount of used space on partition (/dev/sdb1) , delete oldest folder if disk usage above 75%.

i'm thinking step 2 need in loop perhaps. can delete 1 backup @ time. recheck space available, , delete folder if we're still above 75%.

i'm assuming possible bash scripts. i'm still new them. i've found whilst googling around should pretty straight forward knows doing. i'm having trouble figuring out how piece elements together.

here old script, not use after have migrated rsnapshot. have hardcoded strings, hope modify needs. measures free space in gigabytes, not percents. rsnapshot not need anymore purposes.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -