The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Enhanced Backup Retention & Rotation for Backups on Remote FTP Servers

Discussion in 'Data Protection' started by AaronWJM360, Dec 30, 2012.

Thread Status:
Not open for further replies.
  1. AaronWJM360

    AaronWJM360 Registered

    Joined:
    Dec 30, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi Guys!

    I have created a script which enhances the backups retention and rotation for any backups stored on remote FTP servers. It is very useful to me so would like to share it with the cPanel community.

    With the standard cPanel backups at the time of writing this, you can only have one copy of the daily backups, one copy of the weekly backups and one copy of the monthly backups. This can be an issue if you had a problem with a site 2 or 3 days ago, as you will not have the backup for this, apart from a possible weekly backup which you could have made many changes since then.

    The script I have created will connect to the remote FTP server and check for any folders named 'daily', which is the default naming scheme for cPanel backups. It will then rename it with the current date, making it 'daily.301212'. It will also do the same for weekly and monthly backups too.

    The script will also check any folders with a date set to a certain age. For example, I currently have the daily backups rotation set to 7, which means any daily backups older than 7 days will be automatically deleted. This will stop any FTP drives from filling up with backups.

    To run the scripts, I would recommend placing them in a non-public accessible folder within your home directory in cPanel, and running a daily cron job on each PHP file. Here are the cron jobs I have set up for myself (you will need to alter them to suit your environment):

    0 9 * * * php -q /home/awjmho/backup-controller/daily.php
    0 9 * * * php -q /home/awjmho/backup-controller/weekly.php
    0 9 * * * php -q /home/awjmho/backup-controller/monthly.php

    For the script to work successfully, you will need to edit the FTP host, username and password within the 'configuration.php' file and set the rotation value on line 3 in every other file (daily.php/weekly.php/monthly.php). It is self explanatory once you open the file.

    I hope this is useful to someone.

    I will not be held liable for any damage caused by this script, use and implementation of this script is entirely at your own risk.
     
    #1 AaronWJM360, Dec 30, 2012
    Last edited by a moderator: Dec 30, 2012
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,472
    Likes Received:
    200
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    This sort of post should be made on the cPanel Application Catalog site here:
    cPanel App Catalog
     
Loading...
Thread Status:
Not open for further replies.

Share This Page