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.

Backing up the system w/ SCSI Tape Drive

Discussion in 'Data Protection' started by dceola, Oct 22, 2008.

  1. dceola

    dceola Registered

    Joined:
    Oct 20, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Howdy folks! I'm still fairly new to cpanel & linux in general, however have been doing a handfull of research with respect to configuring a reliable backup system for my webserver.

    I have an HP LTO1 SCSI tape drive in my server, which i fully intend to use as a backup device for my system (on top of the raid5 drives already in the system).

    From within the system console, i have successfully been able to manipulate the tape drive using the linux 'mt' commands (the drive is at /dev/st0). However i reckon the Backup utilities built into cPanel do not directly work w/ tape drives, as i tried to enter /dev/st0 as the destination and it didn't take that as a valid destination.

    I looked that for a bit, before i found the opensource backup program called Amanda, which i have been in the process of setting up.

    At this point, i have two main questions that i am posing here:

    1) Is there any way to make the cPanel backup properly backup the system to a tape drive? If so, does this backup the entire system, such that I could restore from scratch if necessary, or just the cPanel related items (such that i would have to load the OS before restoring from the tape drive).
    I would prefer being able to restore the entire system from a blank slate, rather than being forced to install the os, and then cpanel, before performing the restore.

    ---by the way, i did find this post, which i read, and don't fully understand http://forums.cpanel.net/showthread.php?t=15480&highlight=tape+drive (has to do w/ cpanel backup and tape drives...)

    2)If cPanel doesn't support tape backup systems, what directories do i need to make certain that i have amanda back up, to ensure that I do indeed backup everything that is necessary to restore the system, should something happen? also, and i've posted this question elsewhere, anyone know if Amanda backs up msSQL databases, and open files properly? I have been unable to find documentation regarding that specifically.


    Thanks in advance for any help/advice anyone might be able to pose.
     
  2. dceola

    dceola Registered

    Joined:
    Oct 20, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Would this not be the right place to ask this? I'm wondering if i should open a support ticket for this instead...
     
  3. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    As you already deduced, we don't support tape drives as backup destinations.

    A potential work around is to configure cPanel Backup to store backups on a secondary drive mounted at /backup (the directory name is arbitrary, as long as it is entered correctly in the backup configuration). Then create /scripts/postcpbackup to copy /backups to the tape drive.

    I've never used Amanda, so cannot answer questions regarding it.

    If you need help creating the /scripts/postcpbackup script, let me know.
     
  4. HorburySchool

    HorburySchool Active Member

    Joined:
    Dec 14, 2007
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    Personally, I have a shell script that runs via root's crontab that backs up my cPanel server nicely... backs up mysql databases to tar.gz files, backs all data (including the mysqlbackups) up to 2nd harddrive (full daily backup into folders for each day) and then does a full daily backup to tape also.

    Here are the 3x scripts...

    1. fullbackup.sh

    Code:
    #!/bin/sh
    #
    # majordomo alias file
    # Copyright 2000 Troy P. Bahan
    #
    # Available from http://www.freebsddiary.org/samples/dump.sh.txt
    #
    # See http://www.freebsddiary.org/dump-restore.php
    #
    
    #Run Disk-to-Disk backup
      echo "Beginning backup to internal disk..."
      echo " "
      /root/tools/backup/backuptodisk.pl
      echo " "
      echo "Backup to Hard Disk Complete"
      echo " "
    
    #Now start Disk-to-Tape backup
      echo "Beginning backup to tape..."
      echo " "
      TARGET=/dev/sa0
      FILESYSTEMS=/:/home:/tmp:/usr:/var:
      DUMPLEVEL=0
      DUMPOPTIONS=au
      MTACTION=rewind
    
      MT=/usr/bin/mt
      SED=/usr/bin/sed
      DUMP=/sbin/dump
      SH=/bin/sh
    
    #Rewind the tape
      echo "${MT} ${MTACTION}"
      ${MT} ${MTACTION}
    #Do the dump for each file system
      for i in `echo $FILESYSTEMS | ${SED} 's/:/ /g'`
      do
              echo "${DUMP} ${DUMPLEVEL}${DUMPOPTIONS}f ${TARGET} $i"
              ${DUMP} ${DUMPLEVEL}${DUMPOPTIONS}f ${TARGET} $i
      done
    #Rewind the tape
      echo "${MT} ${MTACTION}"
      ${MT} ${MTACTION}
      ${MT} offline
    
      echo "Backups completed, tape rewound and ejected."
    
    exit();
    
    2 - backuptodisk.pl
    Code:
    #!/usr/bin/perl
    
    #       Part of a group of programs to admin a FreeBSD web/email server.
    #       Do what you want with it, just keep the copyright.
    #
    #       Copyright 2004, Erin Fortenberry
    #
    #       $Id: backup.pl,v 1.2 2004/08/26 21:01:19 erinf Exp $
    #
    #       usage: "scriptname -h"
    #
    #       I use /backup as my backup drive and it is nfs mounted.
    #       You can remove the compression on this, but it adds alot
    #       to the backup time so I did not make a switch for it.
    #
    #       The current backup directory it /backup/$hostname/$day.$name.dump.gz
    #
    #       This script does not check to see if the backup directories exist or
    #       if they have enough space for the dump file.
    #
    #       Requires perl 5.6.1 or newer.
    #
    
    
    
    use strict;
    use warnings;
    use Getopt::Std;
    use POSIX qw(strftime);
    use vars qw($VERSION);
    
    $Getopt::Std::STANDARD_HELP_VERSION = 1;
    $VERSION = '1.2';
    
    my @FS = ('/', '/home', '/usr', '/var');
    my $day = lc(strftime "%A", localtime);
    my $hostname = `/bin/hostname -s`;
    my %opt = ('F' => 0, 'd' => 0, 'h' => 0);
    my $type;
    
    chomp $hostname;
    
    getopts("Fdh",\%opt);
    
    if ( $opt{h} == 1 ) {
    
            print STDERR << "EOF";
    
        usage: $0 [-hqd]
    
         -h        : this (help) message
         -d        : Dry run, only print what I am going to do
         -F        : Force full backup {type 0}
    
        example: $0 -h -q -d
    
    EOF
            exit(0)
    }
    
    if ( $opt{F} == 1 ) {
    
            $type = "0"
    
    } else {
    
            if ($day eq "sunday") {
                    $type = "0"
            } else {
                    $type = "0"
            }
    
    }
    
    foreach (@FS) {
    
            my $name = $_;
    
            if ($name eq '/') {
                    $name = '/root';
            };
    
            $name =~ s/^\///g;
    
    # Unncomment for /backup/$day/$name.dump.gz
            my $command = '/sbin/dump -' . $type  . ' -auf - ' .  $_ . ' |
    gzip -q > /backup/' . $day . '/' .
    $name . '.dump.gz';
    
    # Put a "#" in front of the next line if you uncomment the last line
    #       my $command = '/sbin/dump -' . $type  . ' -auf - ' .  $_ . ' | gzip -q > /backup/' . $hostname .
    '/' . $day . '.' . $name . '.dump.gz';
    
            if ($opt{d}) {
                    print($command . "\n");
            } else {
                    system($command);
            };
    };
    
    
    exit(0);
    
    3 - mysqlbackup.sh
    Code:
    #!/bin/sh
    
      USER=
      PASS=
      TARGET=/home/horbury/backup_mysql
      DUMPPATH=/usr/local/bin
      echo "Performing database dumps..."
    
      $DUMPPATH/mysqldump --opt -h localhost -u $USER -p$PASS horbury_dppd06 >$TARGET/dppd06.sql
      $DUMPPATH/mysqldump --opt -h localhost -u $USER -p$PASS horbury_icthelpdesk >$TARGET/hesk.sql
      $DUMPPATH/mysqldump --opt -h localhost -u $USER -p$PASS horbury_markbook >$TARGET/markbook.sql
      $DUMPPATH/mysqldump --skip-opt -h localhost -u $USER -p$PASS horbury_moodle >$TARGET/moodle.sql
      $DUMPPATH/mysqldump --opt -h localhost -u $USER -p$PASS horbury_strict >$TARGET/strict.sql
      $DUMPPATH/mysqldump --skip-opt -h localhost -u $USER -p$PASS horbury_wb >$TARGET/wb.sql
      $DUMPPATH/mysqldump --opt -h localhost -u $USER -p$PASS horbury_mrbs >$TARGET/mrbs.sql
    
      echo "Tarballing succesful dump files..."
    
      tar -czf /home/horbury/backup_mysql/dppd06_sql.tar.gz /home/horbury/backup_mysql/dppd06.sql
      tar -czf /home/horbury/backup_mysql/hesk_sql.tar.gz /home/horbury/backup_mysql/hesk.sql
      tar -czf /home/horbury/backup_mysql/markbook_sql.tar.gz /home/horbury/backup_mysql/markbook.sql
      tar -czf /home/horbury/backup_mysql/moodle_sql.tar.gz /home/horbury/backup_mysql/moodle.sql
      tar -czf /home/horbury/backup_mysql/strict_sql.tar.gz /home/horbury/backup_mysql/strict.sql
      tar -czf /home/horbury/backup_mysql/wb_sql.tar.gz /home/horbury/backup_mysql/wb.sql
      tar -czf /home/horbury/backup_mysql/mrbs_sql.tar.gz /home/horbury/backup_mysql/mrbs.sql
    
      echo "Deleting original dump files, leaving only tarballs..."
    
      rm /home/horbury/backup_mysql/dppd06.sql
      rm /home/horbury/backup_mysql/hesk.sql
      rm /home/horbury/backup_mysql/markbook.sql
      rm /home/horbury/backup_mysql/moodle.sql
      rm /home/horbury/backup_mysql/strict.sql
      rm /home/horbury/backup_mysql/wb.sql
      rm /home/horbury/backup_mysql/mrbs.sql
    
      echo "MySQL Backups completed."
      exit();
    
    Cronjob runs mysqlbackup.sh, then fullbackup.sh (which calls backuptodisk.pl) - these run in the early hours of the morning. All I have to do is remember to change tapes each evening before I leave work.
     
  5. dceola

    dceola Registered

    Joined:
    Oct 20, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    With your above solution, do you have to add lines for each mysql db in your system? or am i understanding that incorrectly. It would seem that in an environment where your cpanel resellers/users could be adding features from Fantistico, having to add a line for each mysql db would not be a very good option.
     
  6. dceola

    dceola Registered

    Joined:
    Oct 20, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    one thought- with a seemingly custom script such as the above- how easy is it to restore files from the tapes? Or even restore the entire system in the event of a crash, or something of the sort?
     
  7. HorburySchool

    HorburySchool Active Member

    Joined:
    Dec 14, 2007
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    The scripts work for my needs, but adapt to suit yours. With master sql user/pass can easily tell it to dump all databases without needing to specify individual names. man mysqldump should tell you how.

    Restoring - from hdd backup, untar/gz then use restore command... works easy enough for individual files or full filesystems. Restoring from tape is just regular restore procedure in accordance to man restore / man dump.

    Just tweak it to suit your needs. I'll be the first to admit it ain't elegant, but it's functional.
     
Loading...

Share This Page