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.

How to keep daily backup ?

Discussion in 'Data Protection' started by lafactory.com, Jun 19, 2008.

  1. lafactory.com

    lafactory.com Member

    Joined:
    Oct 30, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hi, do you know to edit the cpbackup script in order to keep daily backup ? as you they are replaced every night by a new one and I would like to keep the whole week.
     
  2. bhd

    bhd Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    149
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    JNB ZA
    cPanel Access Level:
    Root Administrator
    A simple solution would be to rename the /path/to/cpbackup/daily to something else after the backup (It gets created if it does not exist). You could do that with a one-liner in a cron
     
  3. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    If the number of domains are less then you can rsync the data from daily backup to other folder. You can set cron to rsync the data to other dierctories.

    Kailash
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Or just create /scripts/postcpbackup which is triggered as soon as the backup is completed by cpbackup :).
     
  5. lafactory.com

    lafactory.com Member

    Joined:
    Oct 30, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    yes, renaming with daily date would be simple. But I don't know how to do even such a simple script...
     
  6. lafactory.com

    lafactory.com Member

    Joined:
    Oct 30, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    nice trick, I just did it, but I still need to add something inside, I know, I really need learning linux :)
     
  7. Jamesmaps

    Jamesmaps Member

    Joined:
    May 17, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Anyone have an example script that would do this?
     
  8. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    18
    Here are a couple of scripts I use...

    This first one runs on my remote backup server. It connects to the cPanel server and pulls down a copy of the latest daily backup. The 'key' variable refers to public/private keys that are used to automate the login via ssh.

    Code:
    #!/bin/sh
    
    RSYNC=/usr/bin/rsync
    SSH=/usr/bin/ssh
    KEY=/home/cyabackup/cron/backup-sync-key
    RUSER=cyabackup
    RHOST=cpanel.host.ip.address
    RPATH=/backups/cpbackup
    LPATH=/backup/svr02
    LOG=svr02-rsync.log
    EMAIL=your@email.address
    
    
    rm -f $LPATH/*.log;
    $RSYNC -avz -e "$SSH -p 22 -i $KEY" $RUSER@$RHOST:$RPATH/daily /$LPATH >> $LPATH/$LOG;

    This script runs on the remote backup server. It rotates the daily backups.
    Dateformat ends up being a three-letter code for the day of the week, such as MON TUE WED, etc.

    Code:
    #!/bin/sh
    
    # This script rotates the backup files daily, keeping 7 days worth.
    
    DATEFORMAT=$(date +%a)
    BACKUPSOURCE=/Data/backup/svr02
    BACKUPDEST=/Data/backup/rotation/
    
    rm -Rf $BACKUPDEST/$DATEFORMAT
    mkdir $BACKUPDEST/$DATEFORMAT
    cp -R $BACKUPSOURCE/* $BACKUPDEST/$DATEFORMAT
    
    chmod -R 755 $BACKUPDEST
    Hopefully those will help get you started.
     
  9. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    I've done one here, which will rotate the last N copies of daily, weekly, and monthly as requested ... works by putting a short script into postcpbackup:

    http://forums.cpanel.net/showpost.php?p=478685&postcount=10

    Please make any comments there on how you find it, etc, happy to fix any problems ...
     
Loading...

Share This Page