possible bug into /usr/local/ispconfig/server/cron_daily.php

Discussion in 'General' started by maumar, Aug 20, 2013.

  1. maumar

    maumar Member

    My backup stopped by when I upgraded to 3.0.5.3
    Now I have debugged the issue and i report here what i discover

    the issue is that $retval is not equal to zero if there are no web user files

    Code:
                                    if($backup_mode == 'userzip') {
                                            //* Create a .zip backup as web user and include also files owned by apache / nginx user
                                            $web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.zip';
                                            exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -group '.escapeshellarg($web_group).' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $retval);
                                            if($retval == 0) exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -user '.escapeshellarg($http_server_user).' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --update --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file)
                                    } else {
                                            //* Create a tar.gz backup as root user
                                            $web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.tar.gz';
                                            exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
                                    }
                                    if($retval == 0){
                                            chown($web_backup_dir.'/'.$web_backup_file, 'root');
                                            chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
                                            chmod($web_backup_dir.'/'.$web_backup_file, 0750);
                            
                                            //* Insert web backup record in database
                                            //$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
                                            //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
                                            $sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
                                            $app->db->query($sql);
                                            if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
                                    } else {
                                            if(is_file($web_backup_dir.'/'.$web_backup_file)) unlink($web_backup_dir.'/'.$web_backup_file);
                                    }
    
    
    
    
    line 1131
    if there no files :
    Code:
    find . -user '.escapeshellarg($http_server_user)
    
    $retval is = 12

    and below the created file is unlinked
    unlink($web_backup_dir.'/'.$web_backup_file);

    this is true for me
     
  2. maumar

    maumar Member

    one quick and dirty fix can be change last $retval on line 1131

    Code:
    if($retval == 0) exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -user '.escapeshellarg($http_server_user).' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --update --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $_retval); 
    
    change: $tmp_output, $retval);
    into: $tmp_output, $_retval);

    It works for me
     
    Last edited: Aug 21, 2013
  3. maumar

    maumar Member

    Am I the only one to have this issue?

    If u have an hosting w/out www-data files, u should experience this issue, isn't it?
     
  4. florian030

    florian030 Well-Known Member HowtoForge Supporter

    If you have no web-sites for the server running the backup-part from cron_daily the backup-part is skipped.

    You can verify your database with

    Code:
    SELECT * FROM web_domain WHERE server_id = XXX AND (type = 'vhost' OR type = 'vhostsubdomain') AND backup_interval != 'none';
    where XXX is the current server-id.
     
  5. maumar

    maumar Member

    i found that in a freshly installaed server, into log dir I have www-data files


    Code:
    
    -rw-r--r-- 1 www-data root 232268 Aug 24 16:57 error.log
    
    
    

    instead, in older server (where I do not anser Yes when upgrade ask me to change configuration) I have

    Code:
    
     ls -la log/error.log 
    -rw-r--r-- 1 web959 client24 19025 Oct 18  2012 log/error.log
    
    
    for this reason on new server I do not have the issue
     
  6. florian030

    florian030 Well-Known Member HowtoForge Supporter

    I´m not talking about your log-folders. Check you database.
     
  7. maumar

    maumar Member

    Thnx Florian
    I have no issue with databases backup, I have issue with sites backup regarding line 1131.

    So this is the use case:

    1. you have confired backup mode = userzip
    Code:
    if($backup_mode == 'userzip') 
    
    2. there are no file belonging to $http_server_user
    this find returns no files

    Code:
            ' find . -user '.   escapeshellarg($http_server_user)
    
    the zip command in pipe report exit status 12 when zip has nothing to compress

    Code:
    man zip
    12     zip has nothing to do
    
    the var $retval then is equal to 12
    It is not equal to 0, and created backup is wiped, *unlink*
    Code:
                                    if($retval == 0){
                                   [....]
                                   } else {
                                            if(is_file($web_backup_dir.'/'.$web_backup_file)) unlink($web_backup_dir.'/'.$web_backup_file);
    
    
    I am in this use case: $retval is = to 12

    Code:
    $cmd = 'cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).
                                                    ' find . -user '.escapeshellarg($http_server_user).
                                                    ' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --update --symlinks '. escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@';
                                                    echo __LINE__  . " cmd: " . $cmd  . "\n" ;
                                                    exec( $cmd , $tmp_output, $retval);
                                                    echo __LINE__  . " retval: " . $retval . "\n" ;
    
    Not more, not less
    You can reproduce it easily, at your willing
     
    Last edited: Aug 30, 2013
  8. maumar

    maumar Member

    it is $http_server_user
    it's a typo
     
  9. maumar

    maumar Member

    /usr/local/ispconfig/server/cron_daily.php
    line 1131
    $retval = 12

    when there are no $http_server_user owned files under web tree
     
  10. florian030

    florian030 Well-Known Member HowtoForge Supporter

    The backups are only executed, when you have web-domains with backup enabled on the current server - take a look at the sql-query.

    Beside this, i see no reason, why the sql-query is not limited to active-domains (AND active='y') only.
     
  11. maumar

    maumar Member

    Hello Florian
    I have all web domains with backup enabled.
    Backups are excuted every night.
    For some domains it owrks, for other it does not.
    All my domains have no file owned by www-data, a part from some of them that have one or more files into logs dir owned by www-data.
    I have backups for all domains that have some log file owned by www-data.
    I have reported why.
    I have not to check my databases
    My databases are ok.
     

Share This Page