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.

Backup to Remote Server

Discussion in 'General Discussion' started by MySundown, Jun 2, 2003.

  1. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    I looked around these forums and I saw that alot of people were looking for a way to backup to a remote server automagically (as cPanel speaks). I got this off of the DedicatedNow forums and it's working great for everyone there. The instructions are totally in ssh, so if you don't like getting your hands dirty, this isn't the method for you. OK, here I go.

    Part 1: Changing backup settings
    Login to WHM and change them to the following:
    Daily backups,
    Mount disabled,
    Bailout disabled,
    Incremental disabled,
    Config files enabled,
    SQL per account and entire,
    Access logs disabled

    Part 2: Installing ftpbackup
    SSH or Telnet into the server as root
    wget http://netsw.org/net/ip/filetrans/ftp/ftpbackup/ftpbackup-2.1.tar.gz
    tar zxvf ftpbackup-2.1.tar.gz
    cd ftpbackup-2.1
    make
    make install
    close the window

    Part 3: Setting up the script
    SSH or Telnet into the server as root
    pico -w backup.pl
    copy and paste the script below into the window:
    Code:
    #!/usr/bin/perl 
    
    #FTP Server Information here 
    $ftps = "ftp server name here"; 
    $ftpu = "username here"; 
    $ftpp = "password here"; 
    $serv = "server name here"; 
    
    system("/bin/tar cfp - /backup/cpbackup/weekly | gzip | /usr/local/bin/ftpbackup -h $ftps -u $ftpu -p $ftpp -b $serv.tar.gz");
    edit the "FTP Server Information here" variables to match your own (server name is the hostname or IP address of the ftp address where the files will be stored, username and password are for the ftp server, and server name is simply away of naming the files, ex: server1)
    exit Pico by holding Control-X
    answer Yes to save changes
    chmod 755 backup.pl
    If you want the script to run daily:
    mv backup.pl /etc/cron.daily/backup.pl
    If you want the script to run weekly:
    mv backup.pl /etc/cron.weekly/backup.pl
    If you want the script to run monthly:
    mv backup.pl /etc/cron.monthly/backup.pl
    Close the window

    You should be all set right now. You can test the script out by doing:

    cd /
    ./etc/cron.daily/backup.pl

    You'll get the following error message:
    /bin/tar: Removing leading `/' from member names

    but it's ok - it's normal. It happens everytime. The script puts all the individual files into one single tarball which makes backing up to your computer so much easier. Also, it barely uses any system resources since all the files are already tarballed, it can't compress them any further, just combine them. The upload time depends on network traffic, packet loss, etc etc. If both your server and the backup ftp server are within the same datacenter, you should be able to get 10gb transferred in less than 30 minutes - however, I don't have nearly that much space used yet, I'm just speaking from what other people have told me. My backup file is only 400mb ;)

    If you want to host an ftp server on your own computer to backup onto, I recommend CesarFTP, it's freeware and pretty easy to setup :) Hope this post was helpful to at least one person!

    cPanel.net Support Ticket Number:
     
  2. bmcpanel

    bmcpanel Well-Known Member

    Joined:
    Jun 1, 2002
    Messages:
    546
    Likes Received:
    0
    Trophy Points:
    16
    Thanks, dude.

    cPanel.net Support Ticket Number:
     
  3. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    No prob :)

    cPanel.net Support Ticket Number:
     
  4. gracefive

    gracefive Member

    Joined:
    Jan 24, 2003
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    does this back whole server?

    how can you restore/(thur whm restore?)


    thanks

    cPanel.net Support Ticket Number:
     
  5. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    This backs up everything that WHM backs up normally (the /home directory, emails, apache files, mysql db's, etc). If you want it to backup the *entire* server, here's what you would change the script to:

    Code:
    #!/usr/bin/perl 
    
    #FTP Server Information here 
    $ftps = "ftp server name here"; 
    $ftpu = "username here"; 
    $ftpp = "password here"; 
    $serv = "server name here"; 
    
    system("/bin/tar cfp - / | gzip | /usr/local/bin/ftpbackup -h $ftps -u $ftpu -p $ftpp -b $serv.tar.gz");
    cPanel.net Support Ticket Number:
     
  6. boyforeigner

    boyforeigner Well-Known Member

    Joined:
    May 18, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    does it first uses that WHM backup in the same server them those backup are sent via FTP to the other server ?

    Or these script just make a backup itself and send to another server without having to use the WHM backup system.

    My question is because doing a backup to the same HD (WHM backup system) may cause a crash on it (I read it on the forums) and having 2 HD do not gives much security against hackers.

    So I would like to have 2 servers and both with accounts and one would be also a back up from one to another.

    So does your script these job or you recommend another stuff ?

    cPanel.net Support Ticket Number:
     
  7. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    The script uses the backups that WHM creates to send to the other server. You need to have WHM either backup to the main harddrive or a second harddrive in order for the script to work.

    cPanel.net Support Ticket Number:
     
  8. boyforeigner

    boyforeigner Well-Known Member

    Joined:
    May 18, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    is that a way to create the backup directly to the second server?

    cPanel.net Support Ticket Number:
     
  9. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    If you change the script to:
    Code:
    #!/usr/bin/perl 
    
    #FTP Server Information here 
    $ftps = "ftp server name here"; 
    $ftpu = "username here"; 
    $ftpp = "password here"; 
    $serv = "server name here"; 
    
    system("/bin/tar cfp - /home | gzip | /usr/local/bin/ftpbackup -h $ftps -u $ftpu -p $ftpp -b $serv.tar.gz");
    it'll backup all your files directly to the server - however, mysql databases won't be backed up. You could create a seperate script to accomplish this:
    Code:
    #!/usr/bin/perl 
    
    #FTP Server Information here 
    $ftps = "ftp server name here"; 
    $ftpu = "username here"; 
    $ftpp = "password here"; 
    $serv = "server name here"; 
    
    system("/bin/tar cfp - /var/lib/mysql | gzip | /usr/local/bin/ftpbackup -h $ftps -u $ftpu -p $ftpp -b $serv.tar.gz");
    and then upload that file along side that to the cron directory.

    IE: /etc/cron.daily/homebackup.pl and /etc/cron.daily/mysqlbackup.pl

    It's still better to use the WHM backups because they're rather well packed, but if you don't want to, do it as I wrote above.

    cPanel.net Support Ticket Number:
     
  10. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Wow this is good stuff and nicly explained...

    The only problem I see is recovering the back ups, does this allow the WHM recover options to work with the remote backups?

    If so I would be in a state of bliss ;)

    If not can you explain how to recover a back up, for say one account.

    Thank you for this, good karme is due for you now..

    -Charles

    cPanel.net Support Ticket Number:
     
  11. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    OK, here's how I backup an account. I login to the remote backup server (not your usual server) via ftp and download the file to my computer. I then open it using WinZip and extract everything to the directory of my choice. There should then be a tarball for each user. Now you have 2 choices:

    1) Open up the user of your choice using WinZip. Then extract that to a directory. Upload all the files back up to that user's account.

    2) Place the tarball in the /backup/daily directory and then choose to restore backup in WHM. Choose daily and then pick the user you want to restore.

    cPanel.net Support Ticket Number:
     
  12. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    I was thinking you can wget the files from the ftp server from behind a password protected folder. Just download it right to the back up directory.

    Can you do a username and password when doing a wget command?

    And Unix pros?

    Thanks,

    cPanel.net Support Ticket Number:
     
  13. pirania1

    pirania1 Well-Known Member

    Joined:
    May 10, 2003
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Miami, FL
    erm...
    Code:
    http://username:password@server/directory/file.htm
    Nothing difficult here.

    cPanel.net Support Ticket Number:
     
    #13 pirania1, Jun 11, 2003
    Last edited: Jun 11, 2003
  14. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Wow brain freeze, I forgot about that :(

    cPanel.net Support Ticket Number:
     
  15. MySundown

    MySundown Well-Known Member

    Joined:
    Jun 2, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    16
    You wouldn't be able to wget the file directly from the server, well you could, but I don't think WHM could handle it - as it'll be a tarball of all the accounts, not just one. You would have to untar it on the remote server first to break it down to user.tar.gz - then you could use wget and WHM :)

    cPanel.net Support Ticket Number:
     
  16. InfiniteNetwork

    Joined:
    Jun 25, 2003
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Canberra, Australia
    Does the Remote Option in Cpanel 7 virtually do the same thing as this script?

    I just wanna make a decision with which way I wanna do it

    cPanel.net Support Ticket Number:
     
  17. extremeserver

    extremeserver Registered

    Joined:
    Jun 16, 2003
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    after i did everything and put in /home to backup all my drives i still get an error that says sh: -u :command not found

    cPanel.net Support Ticket Number:
     
  18. chakorules

    chakorules Member

    Joined:
    Aug 1, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Wow that is a WICKED command. Does that system command support an exclude? Like if I wanted to exclude a folder? What about excluding two folders?

    cPanel.net Support Ticket Number:
     
  19. roman

    roman Well-Known Member
    PartnerNOC

    Joined:
    Feb 13, 2002
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    We use rsync to backup to a remote server..

    Wouldn't rsync be a better solution as you would only be transfering files that have changed instead of the entire server.

    Am I missing something?

    cPanel.net Support Ticket Number:
     
  20. isputra

    isputra Well-Known Member

    Joined:
    May 3, 2003
    Messages:
    576
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Mbelitar
    so how to do it using rsync ?
     
Loading...

Share This Page