Need Shell Script to delete old backup folder


#1

Hi Team,

I am taking one of important folder every day backup by using cron. That folder name it will store with the current date.

Now my requirement is i need to keep only the current day and last two days backup.

i.e (i want to keep only test_2016-11-04.tgz ,test_2016-11-03.tgz , test_2016-11-02.tgz)

Remaining folder it has to delete automatically. Please let us know how to do in shell script.

Below is my backup folder structure.


#2

Hi

I will recommend rsnapshot it is also a script which has a lot of great features. It is very easy to configure and will do a 3-day retention.

Look at the below link for better idea.

http://www.tecmint.com/rsnapshot-a-file-system-backup-utility-for-linux/