1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Any way of automatically *deleting* scheduled backups?

Discussion in 'Plesk for Linux - 8.x and Older' started by Brainwrap, Jun 15, 2007.

  1. Brainwrap

    Brainwrap Guest

    0
     
    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?
     
  2. crash0verride

    crash0verride Guest

    0
     
    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
     
  3. Brainwrap

    Brainwrap Guest

    0
     
    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
     
  4. breun

    breun Golden Pleskian

    29
     
    Joined:
    Jun 28, 2005
    Messages:
    1,647
    Likes Received:
    0
    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.
     
Loading...