Your user can do it itself whitout any SSh needed...
Here a script to do it :
Put this on a file called back.pl
# -start -----------------------
#!/usr/bin/perl
require "./back.pm";
$|++;
&ReadParameters();
if ($P{'todo'} eq 'makeanddownload')
{
print "Expires: Mon, 06 May 1996 04:57:00 GMTnContent-Disposition: attachment; filename=".&TextDate(time).".sqlnContent-type: application/binarynn";
binmode('STDOUT');
system "$DumpDBCommand";
}
elsif (($P{'todo'} eq 'downloadfile') and $P{'file'})
{
print "Expires: Mon, 06 May 1996 04:57:00 GMTnContent-Disposition: attachment; filename=$P{'file'}nContent-type: application/binarynn";
my $CHUNK_SIZE = 4096;
open(IN, "$DBDumpsDir$DirSeparator$P{'file'}");
binmode('IN');
binmode('STDOUT');
while ( read( 'IN', $data, $CHUNK_SIZE ) ) { print $data };
close IN;
}
elsif ($P{'todo'} eq 'save')
{
print &TopOfPage();
if (!$P{'filename'}) { $filename = &TextDate(time).'.sql' } else { $filename = $P{'filename'} };
print "
Operation: saving DB dump with name '$filename'
";
$code = system "$DumpDBCommand >"$DBDumpsDir$DirSeparator$filename"";
&HoldError("Command
$DumpDBCommand >"$DBDumpsDir$DirSeparator$filename" executed with error") if ($code);
print '
';
print &Form();
print &BottomOfPage();
}
elsif (($P{'todo'} eq 'restore') and $P{'filename'})
{
print &TopOfPage();
print "
Operation: restoring DB with dump '$P{'filename'}'
";
$code = system "$RestoreDBCommand <"$DBDumpsDir$DirSeparator$P{'filename'}"";
&HoldError("Command
$RestoreDBCommand <"$DBDumpsDir$DirSeparator$P{'filename'}" executed with error") if ($code);
print '
';
print &Form();
print &BottomOfPage();
}
elsif (($P{'todo'} eq 'delete') and $P{'files'})
{
print &TopOfPage();
print "
Operation: deleting files.
";
foreach $file(split(/0/, $P{'files'}))
{
unlink ("$DBDumpsDir$DirSeparator$file") || &HoldError("Can not delete file
'$DBDumpsDir$DirSeparator$file'");
}
print '
';
print &Form();
print &BottomOfPage();
}
elsif (($P{'todo'} eq 'upload') and $P{'uploadfilename'})
{
print &TopOfPage();
$filehandle = $MULTIPARTQUERY->param('uploadfilename');
$filename = lc($P{'uploadfilename'});
$filename =~ s!^.*(|/)!!;
print "
Operation: uploading file '$filename'
";
open(OUT, ">$DBDumpsDir$DirSeparator$filename") || &HoldError("Can not save to file
'$DBDumpsDir$DirSeparator$filename'");
binmode OUT;
while (read($filehandle, $buffer, 1024))
{
print OUT $buffer;
}
close OUT;
print '
';
print &Form();
print &BottomOfPage();
}
else
{
print &TopOfPage();
print &Form();
print &BottomOfPage();
}
################################################################################
#
sub TopOfPage
{
return qq{Expires: Mon, 06 May 1996 04:57:00 GMTnContent-type: text/htmlnn
Backup and restore
Backup and restore
};
}
sub Form
{
my $filename = &TextDate(time).'.sql';
my $result = '';
$result = qq{
Select DB dump for delete or restore
};
return $result;
}
sub BottomOfPage
{
return qq{
};
}
sub HoldError
{
print "
Error: @_[0]
n";
}
sub TextDate
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_[0]);
$year = 1900+$year;
++$mon;
if (length($mon)==1) {$mon="0$mon"};
if (length($mday)==1) {$mday="0$mday"};
$_ = "$year-$mon-$mday";
}
sub TextDateTimeSize
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_[0]);
my(@mons) = ('January', 'February', 'March', 'April', 'May', 'June', 'Jule', 'August', 'September', 'October', 'November', 'December');
$year = 1900+$year;
$_ = "$mday $mons[$mon] $year; $hour:$min:$sec";
}
sub ReadParameters
{
use CGI;
$MULTIPARTQUERY = new CGI;
my @params = $MULTIPARTQUERY->param;
my ($line);
foreach $line(@params) { %P -> {"$line"} = join("0", $MULTIPARTQUERY->param("$line")); }
}
# -end------------------------
second file is the config file call it back.pm
# -start------------------------
#############################################################################
# Change the pass / database name / username to match your database
# that you have created before then also the path to your domain
#####################################################
{
$mySQLDBName = 'databasename';
$mySQLHost = 'localhost';
$mySQLUser = 'username';
$mySQLPassword = 'password';
$DBDumpsDir = '/usr/local/psa/home/vhosts/yourdomain.com/cgi-bin/backup';
$DumpDBCommand = "/usr/local/psa/mysql/bin/mysqldump --host=$mySQLHost --user=$mySQLUser --password=$mySQLPassword --add-drop-table $mySQLDBName";
$RestoreDBCommand = "/usr/local/psa/mysql/bin/mysql --host=$mySQLHost --user=$mySQLUser --password=$mySQLPassword $mySQLDBName";
$DirSeparator = '/';
}
# end
#############################################################################
Save this 2 files somewhere on your cgi-bin then chmod 755 the .pl create the backup directory then run it.. If you want to restore a file put that file in the backup directory then run the script !!
This was awesome script usable by your customer installed in 2 mins ;-)