pc.jpg

STOP spending your hard earn money by having someone else fix your Computer. Do it yourself and save a bundle of cash.
Click for more info --> Windows PC Troubleshooting Unleashed!

Backup Your Web Site Home Directory Without Connecting To CPanel

For many webmasters, backing up their web sites is a task that is often neglected. If the server your site is hosted on crashes or you accidentally delete files, do you have a current backup to get your site restored quickly when the server is back online or if you need to switch hosts?

Downloading site backups is the safety net your business depends on when the unexpected occurs.

Having up to date backups is critical in minimizing downtime and lost revenue. Automated backup solutions exist, but if you are looking for a quick and simple way to download a backup with one click, the following script is all you need.

Two versions of the script exist, one for Windows platform and another for Linux running the bash shell. For Windows, you can use Internet Explorer or Firefox. The Linux script was written for Firefox, but can be changed to use other browsers.

These scripts can be easily modified by adding other commands and automated using a scheduler, but the intention was to provide a simple one click process to download backups without the need to connect to CPanel and navigate to the backup section.

   

The only interaction required is logging on to the host when prompted and selecting a folder to download.

Windows Instructions

  1. Create a file on your desktop and give it a name with .bat extension - yourdomain.bat and copy the script into it.
  2. Modify yourdomainname at set hostname=yourdomain.com to your site domain name.
  3. Modify 1234 at set port=1234 to the port number you use to connect to your site CPanel
  4. If you use Firefox, add REM in front of "C:\Program Files\Internet Explorer\iexplore.exe" and remove REM in front of  "C:\Program Files\Mozilla firefox\firefox.exe"
  5. If you have a MYSQL database, modify dbname at set mysql=dbname to the name of the database and remove REM at the last two lines in the script.

REM #################################################################
REM      Web Host Admin Tip from http://www.watchingthenet.com
REM #################################################################
@echo off

set HOSTNAME=yourdomainame
set PORT=1234
set MYSQL=database

for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set MDATE=%%c%%a%%b
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set MM=%%a
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set DD=%%b
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set YY=%%c
IF %MM:~0,1%==0 SET MM=%MM:~1%
IF %DD:~0,1%==0 SET DD=%DD:~1%
set CDATE=%MM%-%DD%-%YY%
"C:\Program Files\Internet Explorer\iexplore.exe" https://%HOSTNAME%:%PORT%/getbackup/backup-%HOSTNAME%-%cdate%.tar.gz
REM "C:\Program Files\Mozilla firefox\firefox.exe" https://%hostname%:%port%/getbackup/backup-%HOSTNAME%-%cdate%.tar.gz
REM @ping -n 11 127.0.0.1>nul
REM "C:\Program Files\Internet Explorer\iexplore.exe" https://%HOSTNAME%:%PORT%/getsqlbackup/%MYSQL%.gz
REM "C:\Program Files\Mozilla firefox\firefox.exe" https://%HOSTNAME%:%PORT%/getsqlbackup/%MYSQL%.gz
exit

Linux Instructions

Modify the variables hostname and port to your domain name and port used to access CPanel
If you have a MYSQL database, un-comment
# at the line for the MYSQL Firefox command. Modify the mysql variable to the name of the database.

#!/bin/sh
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#      Web Host Admin Tip from http://www.watchingthenet.com
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HOSTNAME=yourdomain.com
PORT=1234
MYSQL=dbname
mdate=`date +%Y%m%d`
MM=`date -u '+%m'`
DD=`date -u '+%d'`
cdate=`date +%Y-${MM#0}-${DD#0}`
echo ${cdate}
/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager https://%hostname%:%port%/getbackup/backup-%hostname%-%cdate%.tar.gz
# /Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager https://%hostname%:%port%/getsqlbackup/%mysql%.gz
exit 0

Filed under Web Master Tips by

Comment

Leave a Comment

Subscribe without commenting