• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Any way of automatically *deleting* scheduled backups?

B

Brainwrap

Guest
I have several sites on my server and have set up each domain with up to 3 nightly backups. The problem is that once the limit (3) is reached, of course, it stops running backups. This requires me to manually delete the oldest backup in order for a new one to be run, which kind of defeats the whole point of having an automated backup system.

I was wondering whether there's any way (special cron task?) of telling Plesk to automatically delete the oldest backup each time it needs to run a new one? In the above example, for instance, it would automatically delete the backup from 2 days ago, opening up a slot for todays' backup?
 
Hi,

"ls -lrt" prints the listing of a directory oldest modified first.

Doing it will get you the following:
-rw-rw-r-- 2 root root 1125 2006-08-21 21:59 Address.pm
-rw-r--r-- 2 root root 624 2006-08-21 22:03 Customer.pm
-rw-r--r-- 1 root root 1166 2006-08-21 22:23 Account.pm
-rw-r--r-- 2 root root 1385 2006-08-22 10:48 Person.pm
-rw-r--r-- 1 root root 20 2006-08-22 10:57 testfile.txt
-rw-r--r-- 2 root root 4888 2006-08-22 11:52 Email.pm

use awk to print the files:

awk '{print $8}'

Use sed to show the oldest file

sed -n 2p

use all these commands in backticks, put it into a script, and tell cron to execute the script every day

example:

#!/bin/sh

rm `ls -lrt /whereyourbackups are/ | awk '{print $8}' | sed -n 2p`

Its a bit messy but will do the trick. Also if you have another partition, I would advocate moving the backup onto a drive with more space, because it is always nice to have an extra copy.



ls -lrt | awk '{print $8}' | sed -n 2p
 
Originally posted by crash0verride
Hi...


...Its a bit messy but will do the trick. Also if you have another partition, I would advocate moving the backup onto a drive with more space, because it is always nice to have an extra copy.

Thanks for the suggestion!

Unfortunately, I'm not much of a programmer/terminal-command guy...I was really wondering whether there was some sort of plug-in GUI interface for this sort of thing.

Still, I'll present your solution to my sysadmin guys and see what they think; additional suggestions are welcome...

Thanks again,

--Charles
 
You could also use the find command with the -ctime option (and the -delete option or pipe the results to xargs rm -f). I guess there is no GUI way, but I wouldn't know really as I use another backup tool.
 
Back
Top