Get Paid to Participate - up to $1 per post!     Twitter     Facebook     Google+
Hosting Discussion
 

Hosting Discussion > Web Hosting Forums > Essential Software & Control Panels > [SOLVED] HOW TO: Daily Remote Backup on a cPanel Host
forgot password?



Reply


Old
  Post #1 (permalink)   11-30-2009, 11:26 PM
HD Amateur
 
davet's Avatar
 
Join Date: Jan 2004
Location: Tampa, FL
Posts: 54
Send a message via AIM to davet Send a message via MSN to davet Send a message via Yahoo to davet

Status: davet is offline
I have found this info to be very helpful and it has saved us many times in the past from extended downtime for our sites.

This is how we backup our important sites daily to a remote FTP location.

Create a file in your /home/username/ directory named backup.php with the code below. Then setup a cron to run the file daily. We actually run it 4 times daily.

You don't need your own expensive FTP server either. I use an XP Pro machine with Filezilla server installed to it for our remote FTP server. The XP machine is located right next to my main workstation so I can burn copies to DVD if need be. I use port forwarding within my Verizon FIOS router to point the FTP port to the XP machine.

I can sleep at night now knowing I have a local copy of our most important data.

Don't rely on your hosting provider for backups. If you read most hosting providers' policies they're not responsible for them anyways.

Do the smart thing and start keeping backups of your site to a remote location, on your local computer or one you have physical access to.

Code:
<?php

// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
// This script contains passwords.  KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/)

// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access
$cpuser = "cpanel-username"; // Username used to login to CPanel
$cppass = "cpanel-password"; // Password used to login to CPanel
$domain = "yourdomain.com"; // Domain name where CPanel is run
$skin = "x3"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme

// Info required for FTP host
$ftpuser = "remote-ftp-username"; // Username for FTP account
$ftppass = "remote-ftp-password"; // Password for FTP account
$ftphost = "remote-ftp-hostname"; // Full hostname or IP address for FTP host
$ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)

// Notification information
$notifyemail = "user@domain.com"; // Email address to send results

// Secure or non-secure mode
$secure = 1; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP

// Set to 1 to have web page result appear in your cron log
$debug = 0;

// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********

if ($secure) {
   $url = "ssl://".$domain;
   $port = 2083;
} else {
   $url = $domain;
   $port = 2082;
}

$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connectionů Bailing out!\n"; exit; }

// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);

$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&submit=Generate Backup";

// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");

// Grab response even if we don't do anything with it.
while (!feof($socket)) {
  $response = fgets($socket,4096);
  if ($debug) echo $response;
}

fclose($socket);

?>
__________________
cPanel Hosting
 
 
 


Old
  Post #2 (permalink)   12-01-2009, 09:43 AM
HD Wizard
 
Join Date: Mar 2005
Location: Atlanta, GA
Posts: 2,264

Status: handsonhosting is offline
Some things of note;

1) This will only work for users operating cPanel
2) This will only work if your web host has not disabled the backup system (seems a lot of free or cheap hosts are disabling backups because of resources)
3) This can be resource intensive application if you have a large site. It must pack all files in the site, so if you have a 500MB site, it needs to make a zip file that large which can take valuable resources.

Verify with your host that you are allowed to run this file, and then also verify that you can run it in a cron. Since this does put a load on the server, if you run it during peak operations on a website that doesn't have a lot of resources available you can quickly find your website suspended by the host.

It's a nice script - just be aware of the "what if" scenario.
__________________
Emerson Nogueira
http://www.HandsOnWebHosting.com
cPanel Web Hosting, Domain Registration, Managed VPS Servers
 
 
 


Old
  Post #3 (permalink)   12-01-2009, 10:14 AM
HD Amateur
 
davet's Avatar
 
Join Date: Jan 2004
Location: Tampa, FL
Posts: 54
Send a message via AIM to davet Send a message via MSN to davet Send a message via Yahoo to davet

Status: davet is offline
1) Correct which is why in the title it says "cpanel host"

2) Correct, some cpanel hosts disable the backup feature.

3) Yes anything over 4gig in size can cause a significant load and crash services.

Sites under 4gig shouldn't cause any significant load issues but handsonhosting you are right about checking with the host if you have a large site and want to run this script.
__________________
cPanel Hosting
 
 
 


Old
  Post #4 (permalink)   12-01-2009, 08:16 PM
HD Wizard
 
Join Date: Mar 2005
Location: Atlanta, GA
Posts: 2,264

Status: handsonhosting is offline
Yep - Just wanted to be sure others saw it

And as for the 4GB limit - I've seen many hosts struggle with a 1GB backup, and I've crippled many a machine with just a 500MB backup (when we move sites from one host to our servers).

For most people, a 1GB transfer would take approx 30-40 minutes from one machine to another, so a 4GB would be a LONG time in transit, not to mention the potential of a corrupted backup.

Are you by any chance running an integrity script on the destination server to validate that the backup can be unpacked with no errors? Might be something to experiment with also, this way you're sure the backups work.

One other thing, it looks like it's making just a regular backup with the username. Is it time-stamping within the zip name? Also might be a good thing, this way you can have several backups on your remote machine without overriding the previously transferred file.
__________________
Emerson Nogueira
http://www.HandsOnWebHosting.com
cPanel Web Hosting, Domain Registration, Managed VPS Servers
 
 
 


Old
  Post #5 (permalink)   12-01-2009, 08:40 PM
HD Amateur
 
davet's Avatar
 
Join Date: Jan 2004
Location: Tampa, FL
Posts: 54
Send a message via AIM to davet Send a message via MSN to davet Send a message via Yahoo to davet

Status: davet is offline
We backup our main site http://interactiveonline.com which is 3.2gig in size 4 times daily on a server that has 400 sites on it. It's a quad core processor with 8gig ram and doesn't have any problems with the backup but we do run the script as nice -n19 which runs it at the lowest priority.

We don't run an integrated script on the remote FTP server but I periodically extract the backups to see if they are valid. If you're aware of any such script please keep me posted.

Also yes it does create a time stamp within the file names. Here's an example:

backup-12.1.2009_18-00-02_ioc.tar.gz

Also if you think 4gig takes a long time you should see how long it takes to do our remote backups for the entire server... about 2.5 days.

Not sure how you're handling your remote backups of the entire server but I finally discovered a way to handle it without overloading it (even large sites). See SOLVED: Local & Remote cPanel Backups
__________________
cPanel Hosting
 
 
 


Old
  Post #6 (permalink)   12-02-2009, 10:57 PM
HD Wizard
 
Join Date: Mar 2005
Location: Atlanta, GA
Posts: 2,264

Status: handsonhosting is offline
We actually run r1soft's CDP software on all our machines (and dedicated servers). It does incremental backups every hour including MySQL Databases, and it's integrated with cPanel so a user can restore a single file, a directory or an entire site if they wanted, all from within their browser. Only Databases need to be requested restore through helpdesk, but even then the user can restore an individual table or the entire database. And with backups stored for 4 weeks, there's limited chance of "losing" that important file.

CDP also offers bare metal restores - so if the server crashes, we can sync the entire machine to a new machine and we're back in business quickly. It also offers the verification of the files after transfer etc.

I completed a 145GB site move the other day which took about 6 hours for the move using rsync, but then we had an awesome connection between the two servers. So many hosts limit their transfer speeds, but the place they were moving from didn't have a low cap so we were able to get business done!

Nice backup file with the timestamp. that makes things easy.

With regards to the unpack and verify, you could setup a cron job on the remote machine to run a verify. I could probably whip something together if you're on a Linux system but I think you mentioned Windows earlier. Not aware of any programs off the top of my head that would do something like that automated in Windows - manually, sure - using winzip - but nothing automated that I know off the top.

Two days on a backup is a pain, but at least you're doing backups! So many people don't even do that!
__________________
Emerson Nogueira
http://www.HandsOnWebHosting.com
cPanel Web Hosting, Domain Registration, Managed VPS Servers
 
 
 


Old
  Post #7 (permalink)   12-02-2009, 11:04 PM
HD Amateur
 
davet's Avatar
 
Join Date: Jan 2004
Location: Tampa, FL
Posts: 54
Send a message via AIM to davet Send a message via MSN to davet Send a message via Yahoo to davet

Status: davet is offline
I had considered R1Soft but it seemed too costly and I read a bad review the CEO of BlueHost posted on his blog at http://www.mattheaton.com/?p=150
__________________
cPanel Hosting
 
 
 


Old
  Post #8 (permalink)   12-03-2009, 10:30 AM
HD Wizard
 
Join Date: Mar 2005
Location: Atlanta, GA
Posts: 2,264

Status: handsonhosting is offline
Interesting post. Never experienced the issues that they experienced. We have it running on over 300 servers for the past 3 years or more and haven't had any issues really. ONE issue I remember, resulted in a partial data loss, but that was 2 years ago I think. We have several users restoring sites daily, and even here at HostingDiscussion the backup system has saved this forum a few times. Keep in mind that the blog you saw was from 2008 also - many things could have changed in todays environment, but definitely we didn't experience any major issues with the software after testing and implementing.
__________________
Emerson Nogueira
http://www.HandsOnWebHosting.com
cPanel Web Hosting, Domain Registration, Managed VPS Servers
 
 
 


Old
  Post #9 (permalink)   01-06-2010, 03:29 PM
HD Newbie
 
Join Date: Sep 2009
Posts: 27

Status: arberb is offline
Theres a built in feature in cpanel to do that.
__________________
╫ Arber Beqiraj
♥ Owner Of Dare Devil Hosting
http://www.DareDevilHosting.com
♥ Premium Cpanel Shared & Reseller Hosting
 
 
 


Old
  Post #10 (permalink)   01-06-2010, 05:41 PM
HD Amateur
 
davet's Avatar
 
Join Date: Jan 2004
Location: Tampa, FL
Posts: 54
Send a message via AIM to davet Send a message via MSN to davet Send a message via Yahoo to davet

Status: davet is offline
Quote:
Originally Posted by arberb View Post
Theres a built in feature in cpanel to do that.
To do a full backup yes, but not to schedule it to run daily, weekly or monthly.

The script does use the cpanel backup feature, but allows it to be scheduled.
__________________
cPanel Hosting
 
 
 


Old
  Post #11 (permalink)   01-22-2010, 08:55 AM
HD Newbie
 
Join Date: Jan 2010
Posts: 26

Status: zippyhosts is offline
cpanel has a very good feature of auto backups daily
 
 
 


Old
  Post #12 (permalink)   03-15-2010, 01:39 AM
HD Amateur
 
Join Date: Jun 2008
Posts: 64

Status: WebbyCart is offline
Hi,

Consider using Rsync via SSH, as with rsync, it will only backup what have changed since last backup, thus light on load and resources.

Regards,
Bobby
__________________
WebbyCart.com - Pushing Onwards...
sales@webbycart.com
Fully Managed Servers & VPS | 3rd Party Management & Monitoring | Remote / Offiste Rsync Backup | Outsourced Hosting Support
 
 
 


Old
  Post #13 (permalink)   03-15-2010, 10:58 PM
HD Newbie
 
Join Date: Mar 2010
Posts: 2

Status: IMR-Mike is offline
I've really been needing this for my web host so I can start backing up my servers, thanks so much!
 
 
 


Old
  Post #14 (permalink)   04-21-2010, 05:44 AM
HD Newbie
 
Join Date: Mar 2009
Posts: 29
Send a message via MSN to qualityhostings Send a message via Yahoo to qualityhostings

Status: qualityhostings is offline
Hi
For cPanel automatic backup, check this tool, which is free www.cpsync.net
__________________
Shared,Reseller,Master Reseller,VPS and Dedicated Server Hosting : sunshell hosting com
 
 
 


Old
  Post #15 (permalink)   04-21-2010, 09:17 AM
HD Community Advisor
 
SenseiSteve's Avatar
 
Join Date: Mar 2009
Location: Saint Louis
Posts: 4,945
Send a message via MSN to SenseiSteve

Status: SenseiSteve is offline
Quote:
Originally Posted by qualityhostings View Post
Hi
For cPanel automatic backup, check this tool, which is free www.cpsync.net
Just a side note - not entirely free, but still worth looking it

Quote:
Although cpSync software is free, a user has to purchase a backup package from here to save the backups. All packages will be activated Instantly after the payment.
__________________
ProlimeHost- Dedicated Server Hosting & KVM SSD VPS
Three Datacenter Locations: Los Angeles, Denver & Singapore
SuperMicro Hardware | Multiple Bandwidth Providers | 24/7 On Site Engineers
 
 
 
Reply
Previous Thread Next Thread


Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Sponsored By: