コード例 #1
0
 public function build($runData)
 {
     // get current backups
     $site = $runData->getTemp("site");
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $sb = DB_SiteBackupPeer::instance()->selectOne($c);
     if ($sb) {
         if ($sb->getStatus() == "completed") {
             // get backup file size
             $path = WIKIDOT_ROOT . '/web/files--sites/' . $site->getUnixName() . '/backup/' . $sb->getRand() . '/backup.zip';
             // check if file exists
             if (!file_exists($path)) {
                 // in case something failed
                 DB_SiteBackupPeer::instance()->delete($c);
                 $sb = null;
             } else {
                 $size = filesize($path);
                 $sizeFormatted = FileHelper::formatSize($size);
                 $runData->contextAdd('size', $sizeFormatted);
             }
         }
     }
     $runData->contextAdd("site", $site);
     $runData->contextAdd("backup", $sb);
 }
コード例 #2
0
 public function run()
 {
     // check!
     $c = new Criteria();
     $c->add("status", null);
     $c->addOrderDescending("backup_id");
     $sb = DB_SiteBackupPeer::instance()->selectOne($c);
     // select only one!
     if (!$sb) {
         return;
     }
     $db = Database::connection();
     $sb->setStatus("started");
     $sb->save();
     $db->begin();
     try {
         $b = new Backuper();
         $b->setConfig($sb);
         $b->backup();
         // check
         $sb->setStatus("completed");
         $sb->setDate(new ODate());
         $sb->setRand($b->getRand());
         $sb->save();
     } catch (Exception $e) {
         $sb->setStatus("failed");
         $sb->save();
     }
     $db->commit();
 }
コード例 #3
0
 public function deleteBackupEvent($runData)
 {
     $site = $runData->getTemp("site");
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     DB_SiteBackupPeer::instance()->delete($c);
     @exec('rm -r ' . WIKIDOT_ROOT . '/web/files--sites/' . $site->getUnixName() . '/backup');
 }