Backing Up Your Hosted Website

Hardly anyone hosts their own web servers anymore, and hosting space is cheaper than ever. If you're using shared hosting, rather than a dedicated server, you won't have root access and can't directly follow our rsync setup tutorial.

If you'd like a few tips and tricks to getting using your EVBackup account with shared (non-root) hosting space, read on.

Web Host Requirements

Here are the services that your webhost needs to be able to support in order to backup to your EVBackup account:

  • Shell access (SSH, preferrably but telnet /rsh will work as well)
  • rsync (We only support full backups once per month; all other backups are incremental)
  • cron / crontab (Something needs to run tasks automatically on a scheduled basis)

Administrative Requirements

Put simply, this is a list of required skills that you need to have to be able to effectively setup and manage backing up your hosted web site to your EVBackup account:

  • Familiarity / comfort with command-line tools (e.g.: editors like vi/vim, Emacs, nano, etc.)
  • Some experience with a Unix / POSIX shell (if you get the following joke then you're probably OK)
    mkdir yellow_pages; cat > yellow_pages

Getting Started

If you meet the requirements listed above, then probably the best place to start is with the rsync basics and automation tutorials. The sorts of things that you'll want to back up include:

  • Your web pages.
    • Usually this is found in /var/www or ~/public_html, but this may vary.
    • An easy way to identify the location is to login to the webhost's shell and find the path to where you upload your web pages to.
  • Your database's data files. Take a look at the MySQL backup tutorials for some direction.
  • Data directories. If you upload files (images, zip files, etc.) other than your web pages, then you'll want to back those up too.

Each of these items can be backed up with it's own rsync script, or as separate directives in a single script. Either way works — it all depends upon how much data you have and how often it needs to be backed up. For example, if the source code of your web pages doesn't change all that often — but your database changes daily — then you might want to backup your web pages once per month and your databases daily.

Troubleshooting

Here are some common problems that people encounter when backing up their hosted websites to their EVBackup accounts. If you need further help, please let us know:

No Super User (root or sudo) Access

This is the most common problem you're likely to run into; if you're on a shared hosting server you almost certainly won't have root access. There are two changes that need to be made to our tutorials:

  1. Remove the sudo directive from all commands. This will run your commands as your local user, not root.
  2. Preface your home directory before all the /backup directory paths; e.g. ~/backup. You must do this because you won't have write permissions for the backup directory unless it is located inside your home directory.

  • Show me »
  • « OK Hide this

Example Command Shown in Tutorials

sudo mkdir /backup

Example Command without sudo and with ~ path

mkdir ~/backup

Finding rsync and cron

Some web hosts don't have rsync and cron readily available to you; while others don't have rsync and cron installed. Generally, you find out about this when you type rsync into a SSH terminal and the following is returned:

rsync: command not found

To find out if rsync, cron (or any other Unix tool) is installed, enter the following into the SSH shell.

whereis rsync
whereis cron

If they are installed, you should see something similar to the following:

rsync: /usr/bin/rsync /usr/share/man/man1/rsync.1.gz
cron: /usr/sbin/cron

If they are found, then you can simply substitute the full path to the command:

  • Show me »
  • « OK Hide this

rsync Command Shown in Tutorials

sudo rsync -avz -e "ssh -i /backup/ssh_key" /data user@user.evbackup.com

rsync Command with Full Path, ~ Home Directory, No sudo

/usr/sbin/rsync -avz -e "ssh -i ~/backup/ssh_key" data user@user.evbackup.com

Backing up Multiple Shared Accounts to One EVBackup Account

Essentially, you'll configure an rsync script for each shared hosting account. However, you'll want to put each different account into a different folder on your EVBackup account.

  • Show me »
  • « OK Hide this

For example, suppose that you have three accounts:

  • Account A is a hosted web server with pages stored in ~/public_html
  • Account B is a data server with data stored in ~/data
  • Account C is a database server with MySQL dumps put into ~/backup/db

Website A

rsync -avz -e "ssh -i ~/backup/ssh_key" ~/public_html user@user.evbackup.com:A

Server B

sudo rsync -avz -e "ssh -i ~/backup/ssh_key" ~/data user@user.evbackup.com:B

Database Server C

sudo mysqldump -u dbuser -h localhost -p dbpass --all-databases > ~/backup/db/all.sql
sudo rsync -avz -e "ssh -i ~/backup/ssh_key" ~/backup/db user@user.evbackup.com:C

Opening a Command Prompt in Microsoft Windows