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.

Personal Backup Script

Discussion in 'General Discussion' started by solan, Dec 14, 2003.

  1. solan

    solan Active Member

    Joined:
    Apr 11, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    I've decided because of what happened over the weekend that I'd make my own backup script. I know the one that cpanel has is wonderfull but I had it configured and it wasn't doing what it was suppose to do.. 8.5.4_RELEASE_72

    anywho....

    I made this only because of what happened, this is something that can be enhansed if need be.

    with this script you will need to either edit it to set your backup partition or create the folder /backup I've created these threw files in /home ---

    backup
    tar
    users


    /home/backup {date} {userfilename} # this will start the backup process once you have your script configured to your server! {date} and {userfilename} are physicly typed in .. (exp = /home/backup 12142003 users )

    I've installed only one var for this backup script but more can be added

    ---------------------------------------
    /home/backup
    ---------------------------------------
    #/bin/sh
    clear
    echo "Sarting MySQL Backup";
    cd /var/lib/mysql/
    echo "Taring up the full DB";
    tar -cf mysql_full_$1.tar *
    echo "Zipping up done! -- moving files to transfer folder";
    mv mysql_full_$1.tar /backup
    cd /home
    echo "** Moving to /home for backup process **";
    ./tar $1 $2
    echo "Taring all physcial Client File Complete";
    cd /home
    mv *.tar /backup/
    cd /backup
    echo "Finish moving file for file transfer";
    echo "loggin into remote FTP server";
    ftp ftp.yourdomain.com # change this to your offsite domain or ip
    echo "exiting ftp protocal";
    echo "transfer completed";
    echo "have a wonderfull day";

    ----------------------------------------
    /home/tar
    ----------------------------------------

    #/bin/sh

    if [ -z "$2" ]
    then
    Filename=users # Default, if no filename specified.
    else
    Filename=$2
    fi

    until [ "$name" = change ] # Change to the last user in your users file
    do
    read name # Reads from $Filename
    echo Backing Up $name
    tar -cf $name$1.tar $name
    done <"$Filename" # Redirects stdin to file $Filename.
    # ^^^^^^^^^^^^

    exit 0

    --------------------------------------------
    this works great, you can either remove the ftp part of the script and have it just do a full backup or you can even change the tar to tgz but make sure you change all tar to tgz or what ever extention you want to do. You need to create a file or let the script look for {users} file -- yes you have to create a file with all your current clients usernames ... I'm going to totaly automate this script and make a plugin of wwwaccount or add the a few lines to the script to add the username to the /home/users file. I also plan on creating a php web interface for this most likely perl, but it will do pretty much the same thing but it will print the echo's. This will be a good way for any of my helpers to backup the server's mission critical data if I'm away.

    As of now I haven't been able to use anything or make var's for the ftp part of the backup :confused: ... hopefull this is where you guys come in.

    Right now I can do the command for ftp

    put *.* and it only transfers one file ??? any help

    I'm just useing the simple ftp protocal, if something else is needed to be installed for a better function then let me know :D :cool:
     
    #1 solan, Dec 14, 2003
    Last edited: Dec 14, 2003
  2. solan

    solan Active Member

    Joined:
    Apr 11, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    The backup script can also have this added to it for umounted drives.


    #/bin/sh

    clear
    echo "Sarting MySQL Backup";
    cd /var/lib/mysql/
    echo "Taring up the full DB";
    tar -cf mysql_full_$1.tar *
    echo "Zipping up done!";
    echo "Please wait while Backup HD is mounted";
    mount /dev/hdc2/ /mnt/hdc2
    mv mysql_full_$1.tar /mnt/hdc2
    cd /home
    echo "** Moving to /home for backup process **";
    ./tar $1
    echo "Taring all physcial Client File Complete";
    cd /home
    mv *.tar /mnt/hdc2/
    cd /mnt/hdc2/
    echo "Finish moving file for file transfer";
    echo "loggin into remote FTP server";
    echo "and starting transfer.";
    ftp ftp.egn-webhosting.net
    echo "exiting ftp protocal";
    echo "transfer completed";
    echo "have a wonderfull day";
    umount /mnt/hdc/



    not to sure if I did the mount and umount correctly.. I'll figure that out when i actualy do have a drive to play with..but you get the picture.
     
Loading...

Share This Page