Koozali.org: home of the SME Server

Howto for Backup2

Offline jumba

  • ****
  • 291
  • +0/-0
  • Donations: July 2007 - $ 20.00
    • Smeserver på svenska!
Howto for Backup2
« Reply #15 on: April 06, 2006, 04:28:55 PM »
Could this contrib also be used to do backups to an external scsi-disk?

Anyone tried?????

Offline dmay

  • *
  • 450
  • +0/-0
    • http://myezserver.com
Howto for Backup2
« Reply #16 on: April 06, 2006, 11:48:03 PM »
Quote from: "jumba"
Could this contrib also be used to do backups to an external scsi-disk?

Anyone tried?????

Yes. It will perform a backup to any mountable ext3 fs storage device.

Darrell

Offline p-jones

  • *
  • 594
  • +0/-0
Howto for Backup2
« Reply #17 on: April 07, 2006, 12:14:51 PM »
I am still no further ahead with this despite checking, checking and more checking of what I have done. It has been sugested that that I have specified the location as \\server\share insteaad of //server/share.

I I put the slashes in the wrong way the logs look like THIS !!!!

Apr  7 22:07:48 server2 esmith::event[6090]: Processing event: pre-backup2-custom 575128
Apr  7 22:07:49 server2 e-smith-bg: Usage: mount.smbfs service mountpoint [-o options,...]
Apr  7 22:07:49 server2 e-smith-bg: Version 3.0.10-1.4E.2
Apr  7 22:07:49 server2 e-smith-bg:
Apr  7 22:07:49 server2 e-smith-bg: Options:
Apr  7 22:07:49 server2 e-smith-bg:       username=<arg>                  SMB username
Apr  7 22:07:49 server2 e-smith-bg:       password=<arg>                  SMB password
Apr  7 22:07:49 server2 e-smith-bg:       credentials=<filename>          file with username/password
Apr  7 22:07:49 server2 e-smith-bg:       krb                             use kerberos (active directory)
Apr  7 22:07:49 server2 e-smith-bg:       netbiosname=<arg>               source NetBIOS name
Apr  7 22:07:49 server2 e-smith-bg:       uid=<arg>                       mount uid or username
Apr  7 22:07:49 server2 e-smith-bg:       gid=<arg>                       mount gid or groupname
Apr  7 22:07:49 server2 e-smith-bg:       port=<arg>                      remote SMB port number
Apr  7 22:07:49 server2 e-smith-bg:       fmask=<arg>                     file umask
Apr  7 22:07:49 server2 e-smith-bg:       dmask=<arg>                     directory umask
Apr  7 22:07:49 server2 e-smith-bg:       debug=<arg>                     debug level
Apr  7 22:07:49 server2 e-smith-bg:       ip=<arg>                        destination host or IP address
Apr  7 22:07:49 server2 e-smith-bg:       workgroup=<arg>                 workgroup on destination
Apr  7 22:07:49 server2 e-smith-bg:       sockopt=<arg>                   TCP socket options
Apr  7 22:07:49 server2 e-smith-bg:       scope=<arg>                     NetBIOS scope
Apr  7 22:07:49 server2 e-smith-bg:       iocharset=<arg>                 Linux charset (iso8859-1, utf8)
Apr  7 22:07:49 server2 e-smith-bg:       codepage=<arg>                  server codepage (cp850)
Apr  7 22:07:49 server2 e-smith-bg:       unicode                         use unicode when communicating with server
Apr  7 22:07:49 server2 e-smith-bg:       lfs                             large file system support
Apr  7 22:07:49 server2 e-smith-bg:       ttl=<arg>                       dircache time to live
Apr  7 22:07:49 server2 e-smith-bg:       guest                           don't prompt for a password
Apr  7 22:07:49 server2 e-smith-bg:       ro                              mount read-only
Apr  7 22:07:49 server2 e-smith-bg:       rw                              mount read-write
Apr  7 22:07:49 server2 e-smith-bg:
Apr  7 22:07:49 server2 e-smith-bg: This command is designed to be run from within /bin/mount by giving
Apr  7 22:07:49 server2 e-smith-bg: the option '-t smbfs'. For example:
Apr  7 22:07:49 server2 e-smith-bg:   mount -t smbfs -o username=tridge,password=foobar //fjall/test /data/test
Apr  7 22:07:49 server2 e-smith-bg: Error occured mounting \\k500\smebackup at /etc/e-smith/events/actions/backup2-backup line 96.
...

Offline p-jones

  • *
  • 594
  • +0/-0
Howto for Backup2
« Reply #18 on: April 07, 2006, 12:26:59 PM »
If I put the slashes the correct way, the logs look like THIS....

Apr  7 22:22:39 server2 esmith::event[7152]: Processing event: pre-backup2-custom 575128
Apr  7 22:22:39 server2 e-smith-bg: 7157: tree connect failed: ERRDOS - ERRnosuchshare (You specified an invalid share name)
Apr  7 22:22:39 server2 e-smith-bg: SMB connection failed
Apr  7 22:22:39 server2 e-smith-bg: Error occured mounting //k500/smebackup/ at /etc/e-smith/events/actions/backup2-backup line 96.

The share most definitely exists and has appropiate R/W permissions.

backup2-backup looks like this:

# Syntax: backup2-backup $BackupJob
#
# Copyright (C) 2003-2006 Darrell May <dmay@myezserver.com>
# --------------------------------------------------------------------

my $BackupJob = $ARGV
  • ;

die "BackupJob argument missing." unless defined ($BackupJob);

$ENV {'QMAILUSER'} = "root";
$ENV {'HOME'} = "/root";
$ENV {'USER'} = "root";

package esmith;

use strict;
use Errno;
use esmith::ConfigDB;
use esmith::util;

# Retrieve db entries
my $db = esmith::ConfigDB->open_ro("backup2");
my $rec = $db->get("$BackupJob");

# Set variables
my $Date = /bin/date +%m.%d.%y;
$Date =~ s/\n//g;
my $Compression = $rec->prop("Compression") || "0";
my $Description = $rec->prop("Description") || "";
my $Destination = $rec->prop("Destination") || "";
my $Exclude = $rec->prop("Exclude") || "";
my @Exclude = split(/,/, "$Exclude");
my $ExcludeList = "/tmp/backup2.$BackupJob.exclude";
my $Expiry = $rec->prop("Expiry") || "";
my $FileSystem = $rec->prop("FileSystem") || "smbfs";
my $IncludeList = "/tmp/backup2.$BackupJob.include";
my $LogFile = "/var/log/backup2/$BackupJob.backup.log";
my $Method = $rec->prop("Method");
my $Mount = $rec->prop("Mount");
my $Password = $rec->prop("Password") || "";
my $Reporting = $rec->prop("Reporting") || "";
my $Size = $rec->prop("Size") || "";
my $Source = $rec->prop("Source") || "";
my @Source = split(/,/, "$Source");
my $Username = $rec->prop("Username") || "";

# rar command options
my $Options="a -idp -ap -dh -ep2 -idc -m$Compression -ol -ow -v$Size" . "m -x\@$ExcludeList";

# -----------------------------------------------------------------------
# Start of generic functions
# -----------------------------------------------------------------------

# Create the inclusion list file
system("/bin/rm -f $IncludeList");
system("/bin/touch $IncludeList");
foreach $Source (@Source)
        {
        system("/bin/echo $Source >> $IncludeList");
        }

# Create the exclusion list file
system("/bin/rm -f $ExcludeList");
system("/bin/touch $ExcludeList");
foreach $Exclude (@Exclude)
        {
        system("/bin/echo $Exclude >> $ExcludeList");
        }

# Launch custom pre-backup2 event
system("/sbin/e-smith/signal-event", "pre-backup2-custom", "$BackupJob") == "0"
                 or die("Error occured during pre-backup2-custom event");

# Backup mySQL databases
if ("$BackupJob" eq "911")
        {
        system("/sbin/e-smith/signal-event", "pre-backup2") == "0"
                     or die("Error occured during pre-backup2 event");
        }

# -----------------------------------------------------------------------
# Start of backup2ws specific functions
# -----------------------------------------------------------------------

if ("$Method" eq "backup2ws")
{
# Create the mount point
system("/bin/mkdir -p /mnt/backup2.$BackupJob");

# Mount the Windows/samba share
system("/bin/umount $Destination > /dev/null 2>&1");
system("/bin/mount -t $FileSystem -o username=$Username,password=$Password $Destination /mnt/backup2.$BackupJob") == "0"
   or die("Error occured mounting $Destination");

# Create the backup directory
system("/bin/mkdir -p /mnt/backup2.$BackupJob/$BackupJob");

if ("$Expiry" eq "")
   {
        system("/bin/rm -f /mnt/backup2.$BackupJob/$BackupJob/$BackupJob.*") == "0"
                   or die("Error occured removing previous backup");
   }
   else
   {
        system("/bin/rm -f /mnt/backup2.$BackupJob/$BackupJob/$BackupJob.$Date.*") == "0"
                        or die("Error occured removing previous backup");

        system("/usr/bin/find /mnt/backup2.$BackupJob/$BackupJob/$BackupJob.* -type f -mtime +$Expiry -exec /bin/rm -f {} \\; > /dev/null 2>&1");
   }

# Backup using rar
system("/usr/bin/rar $Options -- /mnt/backup2.$BackupJob/$BackupJob/$BackupJob.$Date.rar \@$IncludeList > $LogFile");

# Create report file
my $Report = ("/bin/cat << EOF
# ----------------------------------------------------------------
# backup2 report for $Description, job number $BackupJob:
# ----------------------------------------------------------------

Please review the dates, time and sizes of the following:

Actual backup destination = [ $Destination/$BackupJob ]

/bin/ls -l /mnt/backup2.$BackupJob/$BackupJob/$BackupJob.$Date.*

Log file:

/bin/ls -l $LogFile

End of log file reports:

/usr/bin/tail $LogFile
EOF");

# send report to the administrator
if ("$Reporting" eq "enabled")
        {
        system("/bin/mail -s \"backup2 for $Description, job\# $BackupJob report\" admin < $Report");
        }

# Unmount and remove the mount point
if ("$Mount" eq "unmounted")
        {
   system("/bin/umount -f /mnt/backup2.$BackupJob");
   system("/bin/rmdir /mnt/backup2.$BackupJob");
   }
}

# --------------------------------------------------------------------
# Start of backup2usb specific functions
# --------------------------------------------------------------------

if ("$Method" eq "backup2usb")
{
# Mount the USB drive
system("/bin/umount $Destination > /dev/null 2>&1");
system("/bin/mount $Destination") == "0"
   or die("Error occured mounting $Destination");

# Create the backup directory
system("/bin/mkdir -p $Destination/$BackupJob");

if ("$Expiry" eq "")
   {
   system("/bin/rm -f $Destination/$BackupJob/$BackupJob.*") == "0"
                or die("Error occured removing previous backup");
   }
   else
   {
        system("/bin/rm -f $Destination/$BackupJob/$BackupJob.$Date.*") == "0"
                or die("Error occured removing previous backup");

   system("/usr/bin/find $Destination/$BackupJob/$BackupJob.* -type f -mtime +$Expiry -exec /bin/rm -f {} \\; > /dev/null 2>&1");
   }

# Backup using rar
system("/usr/bin/rar $Options -- $Destination/$BackupJob/$BackupJob.$Date.rar \@$IncludeList > $LogFile");

# Create report file
my $Report = ("/bin/cat << EOF
# ----------------------------------------------------------------
# backup2 report for $Description, job number $BackupJob:
# ----------------------------------------------------------------

Please review the dates, time and sizes of the following:

Actual backup destination = [ $Destination/$BackupJob ]

/bin/ls -l $Destination/$BackupJob/$BackupJob.$Date.*

Log file:

/bin/ls -l $LogFile

End of log file reports:

/usr/bin/tail $LogFile
EOF");

# send report to the administrator
if ("$Reporting" eq "enabled")
        {
        system("/bin/mail -s \"backup2 for $Description, job\# $BackupJob report\" admin < $Report");
        }

# Unmount the mount point
if ("$Mount" eq "unmounted")
   {
   system("/bin/umount -f $Destination");
   }

}

# -----------------------------------------------------------------------
# End of specific functions
# -----------------------------------------------------------------------

# Remove the in/exclude files
system("/bin/rm -f $IncludeList > /dev/null 2>&1");
system("/bin/rm -f $ExcludeList > /dev/null 2>&1");

# Remove mySQL dump
if ("$BackupJob" eq "911")
   {
        system("/sbin/e-smith/signal-event", "post-backup") == "0"
                     or die("Error occured during post-backup event");
        }

# Launch custom post-backup2 event
system("/sbin/e-smith/signal-event", "post-backup2-custom", "$BackupJob") == "0"
                     or die("Error occured during post-backup2-custom event");

exit (0);
...

Offline p-jones

  • *
  • 594
  • +0/-0
Howto for Backup2
« Reply #19 on: April 07, 2006, 02:36:14 PM »
Some Breakthroughs - Phew...

Firstly I removed the rpms, reconfigured the system then re installed using YUM. It made no difference to anything.

I next focused on Backup2USB. Wiped the Ext3 partition clean and recreated with Ext2. BINGO, success immeadiately. Moved the USB disk to a windows machine with the IFS Drives/WinRar 3.3 installed and was able to open the backup and extract files.

Next to Backup2Workstation. I had no idea where to go next so in desperation, supplied "administrator" and password. BINGO, more success.

Tried to open the RAR backup file with WinRar 3.3 but failed. Will do another backup overnight and revisit....

In summary,
Problems with Ext3 FS for USB drive (did I miss something somewhere - I thought EXt3 was OK)

A Windows permissions problem with the Wkstn share.

There are others in this thread who had reported similiar issues to mine - hope this helps

P
...

Offline dmay

  • *
  • 450
  • +0/-0
    • http://myezserver.com
Howto for Backup2
« Reply #20 on: April 07, 2006, 05:35:17 PM »
Quote from: "p-jones"
Problems with Ext3 FS for USB drive (did I miss something somewhere - I thought EXt3 was OK)

Yes, ext3 is preferred.

Quote from: "p-jones"
A Windows permissions problem with the Wkstn share.

Are you in a Win ADS domain environment? The account you use must be defined on the local workstation, not in ADS. Next be careful about the password you assign this local account. Keep it simple and do not use non alpha-numeric characters unless you know how to excape these characters. Try these in your testing:

username = backup2
password = backup2

Finally, test mounting your drive from the command line by following the two basic /bin/mount code lines found under this heading you copied above:

# Mount the Windows/samba share

Darrell

Offline p-jones

  • *
  • 594
  • +0/-0
Howto for Backup2
« Reply #21 on: April 07, 2006, 11:46:21 PM »
Hi Darrel

the wkstn is not in a windows Domain however the password does have a non alpha-numeric character to meet V7 security requirements (and map the server share).

The Ext3 bit has really got me confused now.

Cheers
Peter
...