コード例 #1
0
 protected function doMysql($arguments = array(), $options = array())
 {
     $defaults = sfConfig::get('app_csBackup_mysql', array());
     // Override properties in databases.yml with app.yml (for configuration)
     $defaults = array_merge($this->connectionProperties, array_filter($defaults));
     // Override properties in app.yml with directly passed parameters
     $options = array_merge($defaults, array_filter($options));
     // Build mysql backup command
     $cmd = csBackup::buildMysqlBackupCommand($options, $source, $target);
     $this->logSection('backup', 'Backing up files to ' . $target);
     $this->logSection('mysql', $cmd);
     exec($cmd, $messages);
     foreach ($messages as $message) {
         $this->logSection('mysql', $message, null);
     }
 }
コード例 #2
0
 protected function doRsync($arguments = array(), $options = array())
 {
     $defaults = sfConfig::get('app_csBackup_rsync', array());
     $source = $options['source'] ? (array) $options['source'] : $defaults['source'];
     $target = $options['target'] ? $options['target'] : $defaults['target'];
     if (!$source) {
         throw new sfException("At least one RSYNC source must be set in app.yml or passed to the task as --source");
     }
     if (!$target) {
         throw new sfException("the RSYNC target must be set in app.yml or passed to the task as --target");
     }
     foreach ($source as &$s) {
         $s = csBackup::cleanSystemPath($s);
     }
     $cmd = csBackup::buildRsyncCommand($defaults['options'], $source, $target);
     $this->logSection('rsync', $cmd);
     exec($cmd, $messages);
     foreach ($messages as $message) {
         $this->logSection('rsync', $message, null);
     }
 }