Performs backup if necessary.
197367
def setup(self):
        
        if self.backup:
            shutil.copy(self.input_file, "{}.orig".format(self.input_file))
1046163
public function execute()
    {
        $successful = true;
        try {
            // Dump all databases
            $this->databaseManager->dump();

            // Backup folders if specified
            $this->logger->info('[dizda-backup] Copying folders.');
            $this->processorManager->copyFolders();

            // Compress everything
            $this->logger->info(sprintf('[dizda-backup] Compressing to archive using %s', $this->processorManager->getName()));
            $this->processorManager->compress();

            // Transfer with all clients
            $this->clientManager->upload($this->processorManager->getArchivePath());
        } catch (\Exception $e) {
            // Write log
            $this->logger->critical('[dizda-backup] Unexpected exception.', array('exception' => $e));

            $successful = false;
        }

        try {
            // If we catch an exception or not, we would still like to try cleaning up after us
            $this->logger->info('[dizda-backup] Cleaning up after us.');
            $this->processorManager->cleanUp();
        } catch (IOException $e) {
            $this->logger->error('[dizda-backup] Cleaning up failed.', array('exception' => $e));

            return false;
        }

        if ($successful) {
            $this->eventDispatcher->dispatch(BackupEvent::BACKUP_COMPLETED, new BackupEvent());
        }

        return $successful;
    }
172104
def backup_file(*, file, host):
    
    if _driver:
        log.msg_debug("[{driver}] Backing up file '{file}'"
                      .format(driver=_driver.get_name(), file=file))
        _driver.backup_file(file=file, host=host)
466864
protected function backup()
    {
        $from = $this->configFile;
        $pathinfo = pathinfo($from);
        $to = $pathinfo['dirname'] . DIRECTORY_SEPARATOR . $pathinfo['filename'] . '.bak.php';
        $this->file->copy($from, $to);
    }
209047
protected function backup($process)
    {
        if ($process) {
            $this->line('');
            //
            $ok = $this->confirm('Wanna make backup for database ? [yes/no]', false);
            //
            if ($ok) {
                if (Database::export()) {
                    $this->info('The database saved');
                } else {
                    $this->error("The database wasn't saved");
                }
            }
        }
    }
279219
def backup(self, id=None, src=None, timestamp=None):
        
        # Set basic Logging
        logging.basicConfig()
        # Get the lunr logger
        log = logger.get_logger()
        # Output Debug level info
        log.logger.setLevel(logging.DEBUG)
        # Load the local storage configuration
        conf = LunrConfig.from_storage_conf()
        # If no time provided, use current time
        timestamp = timestamp or time()
        # Init our helpers
        volume = VolumeHelper(conf)
        backup = BackupHelper(conf)

        try:
            # Create the snapshot
            snapshot = volume.create_snapshot(src, id, timestamp)

            # For testing non-snapshot speeds
            # snapshot = volume.get(src)
            # snapshot['backup_id'] = id
            # snapshot['origin'] = src
            # snapshot['timestamp'] = 1338410885.0
            # del snapshot['volume']

            print("Created snap-shot: ", pprint(snapshot))

            with self.timeit(snapshot['size']):
                # Backup the snapshot
                print("Starting Backup")
                backup.save(snapshot, id)

        finally:
            # Delete the snapshot if it was created
            if 'snapshot' in locals():
                self._remove_volume(snapshot['path'])
134606
def backup(self, filename='backup.zip', attachments=False):
        """"""
        if self.deploymentType == 'Cloud':
            url = self._options['server'] + '/rest/backup/1/export/runbackup'
            payload = json.dumps({"cbAttachments": attachments})
            self._options['headers']['X-Requested-With'] = 'XMLHttpRequest'
        else:
            url = self._options['server'] + '/secure/admin/XmlBackup.jspa'
            payload = {'filename': filename}
        try:
            r = self._session.post(url, headers=self._options['headers'], data=payload)
            if r.status_code == 200:
                return True
            else:
                logging.warning(
                    'Got %s response from calling backup.' % r.status_code)
                return r.status_code
        except Exception as e:
            logging.error("I see %s", e)
556627
void backupDirs() throws IOException {
    File rootDir = sd.getRootDir();
    FileSystem localFs = FileSystem.getLocal(conf).getRaw();
    NNStorageDirectoryRetentionManager.backupFiles(localFs, rootDir, conf);
  }
213146
public function execute() {
        if ($this->controller->get_status() != backup::STATUS_AWAITING) {
            throw new backup_controller_exception('backup_not_executable_awaiting_required', $this->controller->get_status());
        }
        $this->controller->set_status(backup::STATUS_EXECUTING);
        parent::execute();
        $this->controller->set_status(backup::STATUS_FINISHED_OK);

        if ($this->controller->get_type() === backup::TYPE_1COURSE) {
            // Trigger a course_backup_created event.
            $otherarray = array('format' => $this->controller->get_format(),
                                'mode' => $this->controller->get_mode(),
                                'interactive' => $this->controller->get_interactive(),
                                'type' => $this->controller->get_type(),
            );
            $event = \core\event\course_backup_created::create(array(
                'objectid' => $this->get_courseid(),
                'context' => context_course::instance($this->get_courseid()),
                'other' => $otherarray
            ));
            $event->trigger();
        }
    }
355194
def backup(path, name=None):
    """"""
    from PyHardLinkBackup.phlb.phlb_main import backup

    backup(path, name)
1170964
public static void backup(final String filename) throws IOException {
        final File dest = createFile(filename);
        if (dest.exists()) {
            final File backupFile = generateBackupFilename(filename);
            LOGGER.debug("backing up file from " + filename + " to "
                    + backupFile.getName());
            if (!dest.renameTo(backupFile)) {
                throw new IOException("Could not rename file from "
                        + dest.getName() + " to " + backupFile.getName());
            }
        }
    }
1114502
def restore(self):
        
        if os.path.exists(self.backup_path):
            for file in glob.glob(self.backup_path + "/*"):
                shutil.copy(file, self.path)
671351
private CompletableFuture<BackupResponse> backup(BackupRequest request) {
    return getService(request).thenCompose(service -> service.backup(request));
  }
727950
def backup(self):
        

        LOGGER.debug("> Storing '{0}' file backup.".format(self.__source))

        foundations.common.path_exists(self.__destination) or foundations.io.set_directory(self.__destination)
        destination = os.path.join(self.__destination, os.path.basename(self.__source))
        for i in range(self.__count - 1, 0, -1):
            sfn = "{0}.{1}".format(destination, i)
            dfn = "{0}.{1}".format(destination, i + 1)
            if foundations.common.path_exists(sfn):
                if foundations.common.path_exists(dfn):
                    foundations.io.remove(dfn)
                os.renames(sfn, dfn)
        foundations.common.path_exists(destination) and os.rename(destination, destination + ".1")
        foundations.io.copy(self.__source, destination)
        return True
1346146
static void cleanUpAndCheckBackup(Configuration conf, File origin) throws IOException {
    // get all backups
    String[] backups = getBackups(origin);
    File root = origin.getParentFile();
    
    // maximum total number of backups
    int copiesToKeep = conf.getInt(NN_IMAGE_COPIES_TOKEEP,
        NN_IMAGE_COPIES_TOKEEP_DEFAULT);

    // days to keep, if set to 0 than keep only last backup
    int daysToKeep = conf.getInt(NN_IMAGE_DAYS_TOKEEP,
        NN_IMAGE_DAYS_TOKEEP_DEFAULT);
    
    if (copiesToKeep == 0 && daysToKeep == 0) {
      // Do not delete anything in this case
      // every startup will create extra checkpoint
      return;
    }
    
    // cleanup copies older than daysToKeep
    deleteOldBackups(root, backups, daysToKeep, copiesToKeep);
    
    // check remaining backups
    backups = getBackups(origin);
    if (backups.length >= copiesToKeep) {
      throw new IOException("Exceeded maximum number of standby backups of "
          + origin + " under " + origin.getParentFile() + " max: " + copiesToKeep);
    }
  }
712581
private function _save() : void
    {
        $this->_storage->save(
            $this->_host,
            $this->_storageKey,
            $this->_requestCount,
            $this->_timekeeper->getExpiration(),
            $this->getRemainingSeconds()
        );
    }
1005769
void backupFile() {

        writeLock.lock();

        try {
            if (incBackup) {
                if (fa.isStreamElement(backupFileName)) {
                    fa.removeElement(backupFileName);
                }

                return;
            }

            if (fa.isStreamElement(fileName)) {
                FileArchiver.archive(fileName, backupFileName + ".new",
                                     database.getFileAccess(),
                                     FileArchiver.COMPRESSION_ZIP);
            }
        } catch (IOException e) {
            database.logger.appLog.logContext(e, null);

            throw new HsqlException(e.getMessage(), "", 0);
        } finally {
            writeLock.unlock();
        }
    }