protected function _compress()
    {
        $start = microtime(true);
        $this->info( '  Trying to compress files' );
        // code

        $config    = $this->config;
        $exclude   = $config['files']['exclude'];
        $archiver  = $config['archiver'];
        if ( !empty( $config['files']['archiver'] ) )
        {
            $archiver = $config['files']['archiver'];
        }

        /*
         * OPTION Date-Directories
         */
        if ( $config['use_date_directory'] )
        {
            $backupDir = $this->config['backupDir'] . $this->date;
            $filepath  = $backupDir . '/' . $this->dfilename;
            $filename  = $this->dfilename;
        }
        else
        {
            $backupDir = $this->config['backupDir'];
            $filepath  = $backupDir . '/' .  $this->filename;
            $filename  = $this->filename;
        }

        /*
         * DO COMPRESS
         * Exclude info
         */
        
        $_excluded = '';
        if ( !empty( $exclude ) )
        {
            foreach( $exclude as $e )
            {
                switch( $archiver )
                {
                    case 'tar.gzip':
                        $_excluded .= " --exclude='" . str_replace( base_path() . '/', null, $e ) . "'";
                    break;
                    case 'zip':
                        $_excluded .= " -x '*" . str_replace( base_path() . '/', null, $e ) . "/*'";
                    break;
                    case 'rar':
                        $_excluded .= " -x*" . str_replace( base_path() . '/', null, addslashes( $e ) ) . '\*';
                    break;
                }
            }
        }

        $cmd = [];
        $cmd[] = 'cd ' . base_path();
        switch( $archiver )
        {
            default:
            case 'tar.gzip':
                $_extension     = '.tar.gz ';
                $cmd[]          = 'tar '. $_excluded .' -czvf ' . str_replace( base_path() . '/', null,  $filepath ) . $_extension . ' -C ' . base_path() . ' .';
            break;
            case 'zip':
                $_extension     = '.zip ';
                $cmd[]          = 'zip -r9 ' . $filepath. $_extension . ' ./ ' . $_excluded;
            break;
            case 'rar':
                $_extension     = '.rar ';
                $cmd[]          = 'rar a -r -ep1 -m5 ' . $filepath.$_extension . './' . $_excluded;
            break;
        }
        $this->_runCmd( $cmd );

        // code
        $time = microtime(true)-$start;
        $this->warn( '  Backup filename is ' . $filename.$_extension );
        $this->warn( '                  at ' . str_replace( base_path() . '/', null, $backupDir ) );
    }
protected function _compress()
    {
        $start = microtime(true);
        $this->info( '  Trying to compress files' );
        // code

        $config    = $this->config;
        $exclude   = $config['files']['exclude'];
        $archiver  = $config['archiver'];
        if ( !empty( $config['files']['archiver'] ) )
        {
            $archiver = $config['files']['archiver'];
        }

        /*
         * OPTION Date-Directories
         */
        if ( $config['use_date_directory'] )
        {
            $backupDir = $this->config['backupDir'] . $this->date;
            $filepath  = $backupDir . '/' . $this->dfilename;
            $filename  = $this->dfilename;
        }
        else
        {
            $backupDir = $this->config['backupDir'];
            $filepath  = $backupDir . '/' .  $this->filename;
            $filename  = $this->filename;
        }

        /*
         * DO COMPRESS
         * Exclude info
         */
        
        $_excluded = '';
        if ( !empty( $exclude ) )
        {
            foreach( $exclude as $e )
            {
                switch( $archiver )
                {
                    case 'tar.gzip':
                        $_excluded .= " --exclude='" . str_replace( base_path() . '/', null, $e ) . "'";
                    break;
                    case 'zip':
                        $_excluded .= " -x '*" . str_replace( base_path() . '/', null, $e ) . "/*'";
                    break;
                    case 'rar':
                        $_excluded .= " -x*" . str_replace( base_path() . '/', null, addslashes( $e ) ) . '\*';
                    break;
                }
            }
        }

        $cmd = [];
        $cmd[] = 'cd ' . base_path();
        switch( $archiver )
        {
            default:
            case 'tar.gzip':
                $_extension     = '.tar.gz ';
                $cmd[]          = 'tar '. $_excluded .' -czvf ' . str_replace( base_path() . '/', null,  $filepath ) . $_extension . ' -C ' . base_path() . ' .';
            break;
            case 'zip':
                $_extension     = '.zip ';
                $cmd[]          = 'zip -r9 ' . $filepath. $_extension . ' ./ ' . $_excluded;
            break;
            case 'rar':
                $_extension     = '.rar ';
                $cmd[]          = 'rar a -r -ep1 -m5 ' . $filepath.$_extension . './' . $_excluded;
            break;
        }
        $this->_runCmd( $cmd );

        // code
        $time = microtime(true)-$start;
        $this->warn( '  Backup filename is ' . $filename.$_extension );
        $this->warn( '                  at ' . str_replace( base_path() . '/', null, $backupDir ) );
    }
protected function _compress ( ) { $ start = microtime ( true ) ; $ this -> info ( '  Trying to compress files' ) ; // code $ config = $ this -> config ; $ exclude = $ config [ 'files' ] [ 'exclude' ] ; $ archiver = $ config [ 'archiver' ] ; if ( ! empty ( $ config [ 'files' ] [ 'archiver' ] ) ) { $ archiver = $ config [ 'files' ] [ 'archiver' ] ; } /*
         * OPTION Date-Directories
         */ if ( $ config [ 'use_date_directory' ] ) { $ backupDir = $ this -> config [ 'backupDir' ] . $ this -> date ; $ filepath = $ backupDir . '/' . $ this -> dfilename ; $ filename = $ this -> dfilename ; } else { $ backupDir = $ this -> config [ 'backupDir' ] ; $ filepath = $ backupDir . '/' . $ this -> filename ; $ filename = $ this -> filename ; } /*
         * DO COMPRESS
         * Exclude info
         */ $ _excluded = '' ; if ( ! empty ( $ exclude ) ) { foreach ( $ exclude as $ e ) { switch ( $ archiver ) { case 'tar.gzip' : $ _excluded .= " --exclude='" . str_replace ( base_path ( ) . '/' , null , $ e ) . "'" ; break ; case 'zip' : $ _excluded .= " -x '*" . str_replace ( base_path ( ) . '/' , null , $ e ) . "/*'" ; break ; case 'rar' : $ _excluded .= " -x*" . str_replace ( base_path ( ) . '/' , null , addslashes ( $ e ) ) . '\*' ; break ; } } } $ cmd = [ ] ; $ cmd [ ] = 'cd ' . base_path ( ) ; switch ( $ archiver ) { default : case 'tar.gzip' : $ _extension = '.tar.gz ' ; $ cmd [ ] = 'tar ' . $ _excluded . ' -czvf ' . str_replace ( base_path ( ) . '/' , null , $ filepath ) . $ _extension . ' -C ' . base_path ( ) . ' .' ; break ; case 'zip' : $ _extension = '.zip ' ; $ cmd [ ] = 'zip -r9 ' . $ filepath . $ _extension . ' ./ ' . $ _excluded ; break ; case 'rar' : $ _extension = '.rar ' ; $ cmd [ ] = 'rar a -r -ep1 -m5 ' . $ filepath . $ _extension . './' . $ _excluded ; break ; } $ this -> _runCmd ( $ cmd ) ; // code $ time = microtime ( true ) - $ start ; $ this -> warn ( '  Backup filename is ' . $ filename . $ _extension ) ; $ this -> warn ( '                  at ' . str_replace ( base_path ( ) . '/' , null , $ backupDir ) ) ; }
Create database backup
Create database backup