Design & Development, Security, Tutorials

Back that Site Up: A Backup Guide through the ACC


Tweet about this on TwitterShare on FacebookShare on LinkedInEmail this to someone

It’s important to ensure that you always have copies of your files, and to understand how to generate your own backups to avoid losing potentially valuable information. Backups can be useful to recover files in the case of accidental deletion, to revert a site to a previous version if changes don’t work out as planned, or to restore a site after data loss.

A BackUp Guide for Your Site

You may be asking yourself, “Doesn’t pair Networks make backup copies of my files for me?” pair Networks does make backups, but there are some things to keep in mind. pair Networks maintains backups of each server’s hard drive in case the hard drive fails. These backups are only meant to be used for restoration of the entire server after a drive failure and not for individual files or Web hosting accounts. Also, “historical” backups are not maintained. This means that we back up files frequently to keep them as up to date as possible but that we do not necessarily maintain old versions of files. There is the possibility that if you contact us to restore a file from our backups that it may not be the version of the file that you wanted to have restored.

To avoid this issue, you can generate your own backups of your files to store at any time using the Account Control Center (https://my.pair.com). This is especially useful before making any large changes to the site or database, in case you later wish to revert your site to a previous version.
Here is how to back up a directory in your Web hosting account:

Log in to the Account Control Center (https://my.pair.com)

  • Click on “File Management”
  • Browse to the directory you wish to make a backup of:
  • Click “Back Up this Directory”
  • Choose your compression method ( “gzip’ed tar” is recommended)
  • Click “Back Up Selected Directory”
  • A message will appear confirming that the backup is underway

Files backed up in this way will live in a directory in your home directory called “backup” (/usr/home/username/backup). Replace “username” with your pair Networks account username. The exact name of the backup file will be displayed in step 7 above, and will contain the directory being backed up along with the date that the backup was made.
You can also make a backup copy of a database using the Account Control Center (ACC):

  • Log in to the Account Control Center (https://my.pair.com)
  • Click “Manage your Databases” under “Database Management”
  • Select the database you wish to back up
  • Click the “Create Backup” button
  • Enter your MySQL full access user password used for the database in question
  • Click “Create Backup of Database”

When the backup process is completed, the data will be saved to a backup directory in your home directory. The backup will be in SQL dump format. The filename will be the database name and the creation date. Here’s the specific path and filename below:
/usr/home/USERNAME/backup/DBNAME.YYYYMMDD.sql

If you have a software package installed via the Software Installation Manager, a backup of that can be made as follows:

  • Log in to the Account Control Center (https://my.pair.com)
  • Click “Software Installation Manager” under “Add Services”
  • Click the installation you wish to back up
  • Click the “Backup” button for the package

When complete, files for the Web directory of the installation as well as the database (if the package uses a database) will be placed in the “backup” directory in your home directory.

These examples only reflect how to make a one-time backup of your files. For more advanced users, you can also use the ACC to schedule backups to be made of your files at certain time intervals using a cron job. Cron is a standard UNIX utility that allows you to schedule commands for automatic execution at specific intervals. For more information on cron jobs, please visit our Knowledge Base article on the subject:

http://kb.pair.com/f11

In our last article, we discussed how to make a one-time backup of your files. For more advanced users, you can also use the pair Networks Account Control Center (ACC) to schedule backups to be made of your files at certain time intervals using cron. Cron is a standard UNIX utility that allows you to schedule cron jobs, which are commands for automatic execution at specific intervals. For more information about cron jobs, please visit our Knowledge Base article on the subject:

http://kb.pair.com/f11

Here are the steps for creating a cron job that backs up one of your directory’s files or backs up one of your databases:

  • Log in to the Account Control Center.
  • Click on “Manage Cron Jobs” under the “Advanced Features” heading.
  • Click on “Add New Cron Job”.
  • Indicate how often the cron job should run, and click “Proceed”.
  • Select the time interval for the cron job.
  • Enter your backup command (example commands are below) into the “Command To Run” field.
  • Click on “Add Cron Job”.

You will need to use a specific command depending on which directory you wish to back up. Please create only one cron job at a time for each directory whose files you want to back up. The commands below should be typed on one line in the “Command To Run” field when you are creating your cron job. You can also visit the following link to see example commands formatted for easy copying and pasting:

http://kb.pair.com/f11
To back up your home directory, skipping the “www_logs” and “backup” directory, use the following command:

/usr/bin/tar czf /usr/home/username/backup/home.`/bin/date +\%Y\%m\%d`.tar.gz --exclude www_logs --exclude backup /usr/home/username

For accounts with a separate public_html directory (typically, accounts created before June 1, 2011), the public_html directory can be backed up with:

/usr/bin/tar czf /usr/home/username/backup/web.`/bin/date +\%Y\%m\%d`.tar.gz /usr/www/users/username

To back up your public_ftp directory (if you have one):

/usr/bin/tar czf /usr/bin/tar czf /usr/home/username/backup/ftp.`/bin/date +\%Y\%m\%d`.tar.gz /usr/public_ftp/username

To back up your web logs:

/usr/bin/tar czf /usr/home/username/backup/logs.`/bin/date +\%Y\%m\%d`.tar.gz /usr/home/username/www_logs

In all of the commands above, please replace “username” with your pair Networks username.
To back up a particular database, enter the following command in the “Command To Run” field:

/usr/local/bin/mysqldump -hDBXX.PAIR.COM -uDB_USERNAME -pDB_PASSWORD USERNAME_DATABASENAME > /usr/home/USERNAME/backup/
DATABASENAME.`/bin/date +\%Y\%m\%d`

For the above command, you’ll need to replace the following items according to the table below:

DBXX.PAIR.COM – The hostname of the database server the database resides on
DB_USERNAME – The MySQL username for the database in question
DB_PASSWORD – The MySQL password for the username above
USERNAME_DATABASENAME – The full name of the database
USERNAME – Your pair Networks username

Important note: Please understand that using cron jobs to back up your files will keep creating files in your backup directory. We strongly recommend you remove these files periodically, so that your disk usage can be kept under control. We also suggest that you periodically download these backup files to your local computer so that you will have an off-server copy of your data.