Current time: 11-27-2024, 09:48 AM Hello There, Guest! (LoginRegister)


Post Reply 
Nur SQL Backups ohne Web Backups
Author Message
ZooL Offline
Moderator
*****
Moderators

Posts: 3,429
Joined: Jan 2007
Reputation: 79
Post: #11
RE: Nur SQL Backups ohne Web Backups
ok vieleicht nehme ich mich dann dem mal an, die bugs zu entfernen und vieleicht fliesst
es doch in eine RC mit ein und wird durch die Community dann weiter entwickelt oder
entbugt... ich fänd es nicht schlecht...

mfg
06-06-2008 01:18 AM
Visit this user's website Find all posts by this user Quote this message in a reply
fulltilt Offline
Member
***

Posts: 1,225
Joined: Apr 2007
Reputation: 5
Post: #12
RE: Nur SQL Backups ohne Web Backups
Also ich habe jetzt die Web Backups ausschliessen können:

/var/www/ispcp/engine/backup/ispcp-backup-all

geändert von:
Code:
if ($zip eq "bzip2") {
$backup_filename = "$dmn_name-backup-$date.tar.bz2";

$backup_cmd = "$cmd_tar --create --directory=$dmn_dir --bzip2 --file=$dmn_dir/$backup_filename --exclude=logs --exclude=phptmp --exclude=backups --exclude=$backup_filename . 2> $dmn_dir/$backup_filename.log";
        }
elsif ($zip eq "gzip") {
$backup_filename = "$dmn_name-backup-$date.tar.gz";

$backup_cmd = "$cmd_tar --create --directory=$dmn_dir --gzip --file=$dmn_dir/$backup_filename --exclude=logs --exclude=phptmp --exclude=backups --exclude=$backup_filename . 2> $dmn_dir/$backup_filename.log";
}

nach:
Code:
if ($zip eq "bzip2") {
$backup_filename = "$dmn_name-backup-$date.tar.bz2";

$backup_cmd = "";
        }
elsif ($zip eq "gzip") {
$backup_filename = "$dmn_name-backup-$date.tar.gz";

$backup_cmd = "";
}

Jetzt würde ich gerne die SQL Backups ungepackt (als .sql) erstellen lassen, kann mir hier jemand helfen - was müsste ich hier ändern?
Code:
my ($db_filename, $db_compresscmd) = (undef, undef);

if ($zip eq "bzip2") {
$db_filename = "$db_backup_file.bz2";
$db_compresscmd = "$main::cfg{'CMD_BZIP'} --force \'$db_backup_file\'";
}
elsif ($zip eq "gzip") {
$db_filename = "$db_backup_file.gz";
$db_compresscmd = "$main::cfg{'CMD_GZIP'} --force \'$db_backup_file\'";
}
else {
push_el(\@main::el, 'backup_all_engine()', "Backup algorithm not supported: $zip");
return 1;
}

$rs = sys_command($db_backupcmd);

if ($rs == 0) {
$rs = setfmode("$db_backup_file", $domain_uid, $domain_gid, 0660);

if ($rs != 0) {
unlink($db_backup_file);
}
else {
$rs = sys_command($db_compresscmd);
return $rs if ($rs != 0);
}
return $rs if ($rs != 0);
}
else {
push_el(\@main::el, 'backup_all_engine()', "ERROR: Failed to backup database $db_name");
unlink($db_backup_file);
}
06-07-2008 08:57 PM
Find all posts by this user Quote this message in a reply
fulltilt Offline
Member
***

Posts: 1,225
Joined: Apr 2007
Reputation: 5
Post: #13
RE: Nur SQL Backups ohne Web Backups
Das mit den SQL Backups ungepackt habe ich auch hinbekommen.
Allerdings bekomme ich noch die Fehlermeldung zwischendurch ... es werden aber alle SQL Backups angelegt:

Code:
DEBUG: push_el() sub_name: backup_all_engine(), msg: ERROR: tar returned exit status -1, have a look in /var/www/virtual/xxxx.xx/xxxx.xx-backup-2008.06.07-141249.tar.gz.log

Hier ist die komplette Datei falls das jemand testen möchte:
Code:
#!/usr/bin/perl

# ispCP ω (OMEGA) a Virtual Hosting Control Panel
# Copyright (c) 2001-2006 by moleSoftware GmbH
# http://www.molesoftware.com
# Copyright (c) 2006-2007 by isp Control Panel
# http://isp-control.net
#
#
# License:
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the MPL Mozilla Public License
#    as published by the Free Software Foundation; either version 1.1
#    of the License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    MPL Mozilla Public License for more details.
#
#    You may have received a copy of the MPL Mozilla Public License
#    along with this program.
#
#    An on-line copy of the MPL Mozilla Public License can be found
#    http://www.mozilla.org/MPL/MPL-1.1.html
#
#
# The ispCP ω Home Page is at:
#
#    http://isp-control.net
#

use FindBin;
use lib "$FindBin::Bin/..";
require 'ispcp_common_code.pl';

use strict;

use warnings;

sub lock_backup_all_system {

    my ($lock_file) = @_;

    push_el(\@main::el, 'lock_backup_all_system()', 'Starting...');

    if ($main::cfg{'BACKUP_DOMAINS'} ne 'yes') {

        push_el(\@main::el, 'lock_backup_all_system()', 'NOTICE: domain backups are disabled');

        return 2;
    }

    if (-e $lock_file) {

        push_el(\@main::el, 'lock_backup_all_system()', 'ERROR: backup request engine already locked !');

        return 1;

    }

    my $touch_cmd = "$main::cfg{'CMD_TOUCH'} $lock_file";

    my $rs = sys_command($touch_cmd);

    return 1 if ($rs != 0);

    push_el(\@main::el, 'lock_backup_all_system()', 'Ending...');

    return 0;
}


sub unlock_backup_all_system {

    my ($lock_file) = @_;

    push_el(\@main::el, 'unlock_backup_all_system()', 'Starting...');

    my $rs = del_file($lock_file);

    return $rs if ($rs != 0);

    push_el(\@main::el, 'unlock_backup_all_system()', 'Ending...');

    return 0;

}



sub backup_all_start_up {

    my ($lock_file) = @_;

    my ($rs, $rdata) = (undef, undef);

    push_el(\@main::el, 'backup_all_start_up()', 'Starting...');

    $rs = lock_backup_all_system($lock_file);

    return $rs if ($rs != 0);

    # config check;

    $rs = get_conf();

    return $rs if ($rs != 0);

    #
    # getting initial data also must be done here;
    #

    #my $sql = "select * from domain where domain_status = 'ok' ;";

    #($rs, $rdata) = doSQL($sql);

    #return $rs if ($rs != 0);

    push_el(\@main::el, 'backup_all_start_up()', 'Ending...');

    return 0;

}


sub backup_all_shut_down {

    my ($lock_file) = @_;

    my $rs = undef;

    push_el(\@main::el, 'backup_all_shut_down()', 'Starting...');

    $rs = unlock_backup_all_system($lock_file);

    return $rs if ($rs != 0);

    push_el(\@main::el, 'backup_all_shut_down()', 'Ending...');

    return 0;

}

sub err_exit {

    my $el_data = pop_el(\@main::el);

    $main::el_sep = "\t#\t";

    my ($sub_name, $msg) = split(/$main::el_sep/, $el_data);

    print STDERR "$msg\n";

    exit 1;

}

sub backup_all_mail_task {

    my ($rs, $rdata, $sql) = (undef, undef, undef);

    push_el(\@main::el, 'backup_all_mail_task()', 'Starting...');

    $sql = "
        SELECT
                admin_name,
                email
        FROM
            admin
        WHERE
            created_by = 0
    ";

    ($rs, $rdata) = doSQL($sql);

    return $rs if ($rs != 0);

    #
    # no admin data -> no mail message;
    #

    return 0 if (scalar(@$rdata) == 0);

    $rdata = @$rdata[0];

    my $date = get_human_date();

    my ($admin_name, $admin_email) = (@$rdata[0], @$rdata[1]);

    my $dmn_backup_dir = $main::cfg{'BACKUP_FILE_DIR'};

    my $backup_file_list = `ls -la $dmn_backup_dir`;

    my $server_name = $main::cfg{'SERVER_HOSTNAME'};

    my $server_ip = $main::cfg{'BASE_SERVER_IP'};

    my $msg_data = <<MESSAGE_TEXT;
Hey There,

I'm the automatic backup system on your $server_name ($server_ip) server.

Backup task was completed successfully!

File(s) List In ($dmn_backup_dir):

========================================================================
$backup_file_list
========================================================================
MESSAGE_TEXT

    my $out = new MIME::Entity;

    $out -> build(
                From => "Automatic Backup Manager <".$admin_email.">",
                To => $admin_email,
                Subject => "[$date] Backup report.",
                Data => $msg_data,
                'X-Mailer' => "$main::cfg{'VersionH'} Automatic Backup Messanger"
                );

    open MAIL, "| /usr/sbin/sendmail -t -oi";

    $out -> print(\*MAIL);

    close MAIL;

    push_el(\@main::el, 'backup_all_mail_task()', 'Ending...');

    return 0;

}


sub backup_all_engine {

    my ($rs, $rdata, $sql) = (undef, undef, undef);

    my $zip = $main::cfg{ZIP};

    push_el(\@main::el, 'backup_all_engine()', 'Starting...');


    $sql = "
        SELECT
            t1.domain_id,
            t1.domain_name,
            t1.domain_status,
            t1.domain_uid,
            t1.domain_gid,
            t2.admin_name,
            t2.email
        FROM
            domain AS t1,
            admin AS t2
        WHERE
                t1.domain_status    = 'ok'
            AND    t1.domain_admin_id    = t2.admin_id
        ORDER BY
            t1.domain_id
    ";

    ($rs, $rdata) = doSQL($sql);

    return $rs if ($rs != 0);

    my $cmd_tar = $main::cfg{'CMD_TAR'};

    my $cmd_rm = $main::cfg{'CMD_RM'};

    my $cmd_mv = $main::cfg{'CMD_MV'};

    my $httpd_uid = $main::cfg{'APACHE_USER'};

    my $httpd_gid = $main::cfg{'APACHE_GROUP'};

    my ($backup_filename, $backup_cmd) = (undef, undef);

    foreach (@$rdata) {

        my ($dmn_id, $dmn_name, $dmn_status, $domain_uid, $domain_gid, $admin_name, $admin_email) = (@$_[0], @$_[1], @$_[2], @$_[3], @$_[4], @$_[5], @$_[6]);

        my $date = get_human_date();

        my $dmn_dir = $main::cfg{'APACHE_WWW_DIR'}."/$dmn_name";

        my $dmn_backup_dir = $main::cfg{'APACHE_WWW_DIR'}."/$dmn_name/backups";

        if ($zip eq "bzip2") {
            $backup_filename = "$dmn_name-backup-$date.tar.bz2";

            $backup_cmd = "";
        }
        elsif ($zip eq "gzip") {
            $backup_filename = "$dmn_name-backup-$date.tar.gz";

            $backup_cmd = "";
        }

        #
        # User Database Backup
        #

        if (! -d $dmn_backup_dir) {
            $rs = make_dir($dmn_backup_dir, $domain_uid, $domain_gid, 0770);

            return $rs if ($rs != 0);
        }

        #
        # User Database Backup
        # Vorgehensweise - zu der Domain die entsprechenden Datenbanken aus der ISPCP-DB auslesen
        # MYSQLDUMP mit den Datenbanken durchführen und die Ausgabe in das Backup-Verzeichnis umleiten
        #

        $sql="SELECT sqld_id, sqld_name FROM sql_database WHERE domain_id=$dmn_id";
        ($rs,my $rdata3) = doSQL($sql);

        foreach(@$rdata3) {
            my $db_id=@$_[0];
            my $db_name=@$_[1];
            $sql = "SELECT sqlu_name, sqlu_pass FROM sql_user WHERE sqld_id=$db_id LIMIT 1";
            ($rs,my $rdata2) = doSQL($sql);
            my $dbuser = "";
            my $dbpass = "";

            if (@$rdata2) {
                foreach(@$rdata2) {
                    $dbuser = @$_[0];
                    $dbpass = @$_[1];
                }
                if ($dbuser && $dbpass) {
                    my $db_backup_file = "$dmn_backup_dir/$db_name.sql";
                    my $db_backupcmd = "$main::cfg{'CMD_MYSQLDUMP'} --add-drop-table --allow-keywords --quote-names -u\'$dbuser\' -p\'$dbpass\' \'$db_name\' >\'$db_backup_file\'";

                    my ($db_filename, $db_compresscmd) = (undef, undef);

                    if ($zip eq "bzip2") {
                        $db_filename = "$db_backup_file.sql";
                        
                    }
                    elsif ($zip eq "gzip") {
                        $db_filename = "$db_backup_file.sql";
                        
                    }
                    else {
                        push_el(\@main::el, 'backup_all_engine()', "Backup algorithm not supported: $zip");

                        return 1;
                    }

                    $rs = sys_command($db_backupcmd);

                    if ($rs == 0) {
                        $rs = setfmode("$db_backup_file", $domain_uid, $domain_gid, 0660);

                        if ($rs != 0) {
                            unlink($db_backup_file);
                        }
                        
                        return $rs if ($rs != 0);
                    }
                    else {
                        push_el(\@main::el, 'backup_all_engine()', "ERROR: Failed to backup database $db_name");
                        unlink($db_backup_file);
                    }
                }
            }
    
}
        $rs = sys_command($backup_cmd);

        # do not return if backup throws an error, otherwise other domains will not be backuped
        if ($rs == 0) { # everything ok


            $rs = sys_command("$cmd_mv -f $dmn_dir/$backup_filename $dmn_backup_dir");

            return $rs if ($rs != 0);

            $rs = setfmode("$dmn_backup_dir/$backup_filename", $domain_uid, $domain_gid, 0660);

            return $rs if ($rs != 0);

        } else { # some error occurred

            push_el(\@main::el, 'backup_all_engine()', "ERROR: tar returned exit status $rs, have a look in $dmn_dir/$backup_filename.log");

                        if ( -e "$dmn_dir/$backup_filename" ) {

                            $rs = del_file("$dmn_dir/$backup_filename");

                            return $rs if ($rs != 0);

                        }

                }

    }

    push_el(\@main::el, 'backup_all_engine()', 'Ending...');

    return 0;

}


my $rs = undef;

my $proceed = $ARGV[0];


if (!defined($proceed) || $proceed eq '') {

    push_el(\@main::el, 'main()', "ERROR: Missing Input Data! Please provide appropriate command line parameter(s)!");

    err_exit();

}

if ($proceed ne 'yes') {

    push_el(\@main::el, 'main()', "NOTE: If you want full backup of your domain data, please run this script with 'yes' command line parameter!");

    err_exit();

}

my $backup_lock_file = "/tmp/ispcp-backup-all.lock";

$rs = backup_all_start_up($backup_lock_file);

err_exit() if ($rs != 0 && $rs != 2);

exit 0 if ($rs == 2); # $rs == 2 when backups are disabled

$rs = backup_all_engine();

err_exit() if ($rs != 0);

$rs = backup_all_shut_down($backup_lock_file);

err_exit() if ($rs != 0);

exit 0;
(This post was last modified: 06-07-2008 10:27 PM by fulltilt.)
06-07-2008 10:26 PM
Find all posts by this user Quote this message in a reply
xister Offline
Member
*
Beta Team

Posts: 405
Joined: Oct 2006
Reputation: 6
Post: #14
RE: Nur SQL Backups ohne Web Backups
Ich habe das Script (http://hsp-52.hspserver.com/backup.htm) Zuhause leider nicht mehr gefunden aber mich mit dem damaligen Entwickler kurzgeschlossen.
Er stellt uns seinen Code zur freien Verwendung in ispCP sehr gerne bereit.

Er selber programmiert kein php mehr und der Code (beruht noch auf vhcs) ist auch sehr unschön und buggy wie er selber schreibt. Aber vielleicht könnt ihr ja etwas draus machen.

Die Probleme mit dem Modul waren u.A.:

- Fragwürdige Sicherheit (Aufruf mit falschen Parametern um fremden Inhalt rückzusichern)
- Keine Einschränkung der Verwendung. (Es gab 2 Nutzer, die pausenlos Rücksicherungen machten. Findet der Server nicht so schön.)

Hier der Link zum Code:
http://www.diskussionspunkt.de/vhcs_team.tar.bz2

btw:
Vielleicht mag ja auch jemand diesen Text ins englische Forum posten Smile
06-10-2008 09:23 PM
Find all posts by this user Quote this message in a reply
Zothos Offline
Release Manager
*****
Dev Team

Posts: 1,262
Joined: Feb 2007
Reputation: 10
Post: #15
RE: Nur SQL Backups ohne Web Backups
nice, schau ich mir gleich mal an. Smile
06-10-2008 10:03 PM
Find all posts by this user Quote this message in a reply
Zothos Offline
Release Manager
*****
Dev Team

Posts: 1,262
Joined: Feb 2007
Reputation: 10
Post: #16
RE: Nur SQL Backups ohne Web Backups
also der code ist wirklich schlecht. Wird eine rießen arbeit das anzupassen. Würde fast vorschlagen wir nehmen seine engine sachen und den rest bauen wir selbst.
06-11-2008 06:19 AM
Find all posts by this user Quote this message in a reply
ZooL Offline
Moderator
*****
Moderators

Posts: 3,429
Joined: Jan 2007
Reputation: 79
Post: #17
RE: Nur SQL Backups ohne Web Backups
Neu coden ist meistens einfacher.
Und bugfreier als überarbeitung.

danke dir Zothos für das Statement.

MFG
06-11-2008 06:37 AM
Visit this user's website Find all posts by this user Quote this message in a reply
xister Offline
Member
*
Beta Team

Posts: 405
Joined: Oct 2006
Reputation: 6
Post: #18
RE: Nur SQL Backups ohne Web Backups
Denke auch, man kann sich besser Anregungen vom Code und Design holen kann und dann halt selbst anfängt zu coden. Zumal man dann selber besser durchsteigt und weiß, wo was hakt.
06-11-2008 04:37 PM
Find all posts by this user Quote this message in a reply
Zothos Offline
Release Manager
*****
Dev Team

Posts: 1,262
Joined: Feb 2007
Reputation: 10
Post: #19
RE: Nur SQL Backups ohne Web Backups
hier mal ein paar gedanken zu dieser neuen Funktionalität.

- admin kann das ganze global ein und aus schalten
- admin kann das ganze auch für jeden reseller ein und auschalten
- Reseller kann das ganze für seine Kunden ein und ausschalten global
- Reseller kann im hosting plan definieren ob backups ja / nein
- Auch nachträglich ein und auschaltbar über edit
- 3 backup arten domain files | mysql | mail
- Zurückspielen der 3

So das war kurz und knackig die gui, der deamon wird lustiger. Denn das was er gemacht hat ist nur ne quick and dirty lösung. Also nicht zu gebrauchen.

- Anpassung des ispcp-backup-all an die obigen changes

Die eigentliche gui und die db hintendran ist schnell erstellt. Doch der daemon wird interessant, Also, lasst mal hören was ihr davon haltet. Wobei anzumerken ist, frühestens in der rc6/1.0 kann das ganze in den trunk kommen.
06-11-2008 05:26 PM
Find all posts by this user Quote this message in a reply
xister Offline
Member
*
Beta Team

Posts: 405
Joined: Oct 2006
Reputation: 6
Post: #20
RE: Nur SQL Backups ohne Web Backups
ispcp-backup-all wird ohnehin komplett neu geschrieben oder? Smile
Die ist doch auch mehr oder weniger schön und überbleibsel von damals, oder?

Vielleicht sollte der Admin noch festlegen können, wieviele Versionsstände gesichert werden.

Ansonsten ist von mir aus, dem nichts mehr hinzuzufügen.
06-11-2008 05:32 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)