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.

rsync Backup Scripts

Discussion in 'General Discussion' started by Olate, Jan 24, 2004.

  1. Olate

    Olate Active Member

    Joined:
    Aug 1, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    I thought I'd share my rsync backup scripts with everyone. These can be set to run via cron at any time you wish and the output will be e-mailed to you.

    Entire Filesystem

    Code:
    #
    # Daily rsync backup script of entire filesystem onto /backup
    #
    # Last Edited: 8th December 2003 by David Mytton
    #
    
    echo
    echo "***Daily rsync Backup***";
    echo
    echo "$(date +%d-%m-%Y)";
    echo
    echo "Progress:";
    echo
    echo "- Backing up / to /backup/latest";
    echo
    echo "Starting " $(date);
    echo
    
    rsync --archive --verbose --stats --delete --exclude /backup --exclude fstab / $
    
    echo
    echo "Completed " $(date);
    All Databases

    Code:
    #
    # Hourly rsync backup script of MySQL databases onto /backup
    #
    # Last Edited: 13th December 2003 by David Mytton
    #
    
    echo
    echo "***Hourly rsync Backup***";
    echo
    echo "$(date +%d-%m-%Y)";
    echo
    echo "Progress:";
    echo
    echo "- Backing up /var/lib/mysql to /backup/latest";
    echo
    echo "Starting " $(date);
    echo
    
    rsync --archive --verbose --stats --delete /var/lib/mysql /backup/latest/
    
    echo
    echo "Completed " $(date);
    Home Directories

    Code:
    #
    # Hourly rsync backup script of /home onto /backup
    #
    # Last Edited: 8th December 2003 by David Mytton
    #
    
    echo
    echo "***Hourly rsync Backup***";
    echo
    echo "$(date +%d-%m-%Y)";
    echo
    echo "Progress:";
    echo
    echo "- Backing up /home to /backup/latest";
    echo
    echo "Starting " $(date);
    echo
    
    rsync --archive --verbose --stats --delete /home /backup/latest/
    
    echo
    echo "Completed " $(date);
     
  2. Jeewhizz

    Jeewhizz Well-Known Member

    Joined:
    Mar 12, 2003
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    London, England
    Is there a way you could get this to auto-upload this via ftp as well?
     
  3. Olate

    Olate Active Member

    Joined:
    Aug 1, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    rsync can copy to a remote server if you want it to. Look it up in the rsync man entry.
     
  4. fuzzie

    fuzzie Well-Known Member

    Joined:
    Oct 12, 2002
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    Very nice!
    Can you help with backing it up to a remote server.
    I have looked at the man rsync, and am a little confused.

    I think it should be
    rsync -azxWu -e ssh <src IPxxx.xxx.xxx.xxx> <remote IP xxx.xxx.xxx.xxx>:<dst>

    What is <dst>?
     
  5. Olate

    Olate Active Member

    Joined:
    Aug 1, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    <dst> is the destination on the server. For example /backups/server1
     
  6. dysk

    dysk Well-Known Member

    Joined:
    Apr 22, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6
    Hi-
    You all should look at rsnapshot. It allows incremental backups, by using hard links. This way you can use the standard filesstem tools to restore files, and you don't take up a ton of disk space.
    See http://www.rsnapshot.org/ for more info.

    Regards,
    Erek Dyskant
    Unix Consultant
     
  7. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    Thanks for the useful script
     
Loading...

Share This Page