Backup method driver.
19210
def backup(self, paths=None):
        """"""
        if not paths:
            paths = self._get_paths()

        try:
            self._backup_compresslevel(paths)
        except TypeError:
            try:
                self._backup_pb_gui(paths)
            except ImportError:
                self._backup_pb_tqdm(paths)

        # Delete source if specified
        if self.delete_source:
            shutil.rmtree(self.source)
        return self.zip_filename
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();
        }
    }
656548
def create_backup(self):
        

        js = json.dumps({'cmd': 'backup'})
        params = urllib.urlencode({'json': js})
        answer = self._read(self.api_url + 'cmd/system', params)

        return answer[0].get('url')
1057698
def backup(self):
        
        try:
            self.backup_df = self.df.copy()
        except Exception as e:
            self.err(e, "Can not backup data")
            return
        self.ok("Dataframe backed up")
890766
def _restore_backup(self):
        """"""
        input_filename, input_file = self._get_backup_file(database=self.database_name,
                                                           servername=self.servername)
        self.logger.info("Restoring backup for database '%s' and server '%s'",
                         self.database_name, self.servername)
        self.logger.info("Restoring: %s" % input_filename)

        if self.decrypt:
            unencrypted_file, input_filename = utils.unencrypt_file(input_file, input_filename,
                                                                    self.passphrase)
            input_file.close()
            input_file = unencrypted_file
        if self.uncompress:
            uncompressed_file, input_filename = utils.uncompress_file(input_file, input_filename)
            input_file.close()
            input_file = uncompressed_file

        self.logger.info("Restore tempfile created: %s", utils.handle_size(input_file))
        if self.interactive:
            self._ask_confirmation()

        input_file.seek(0)
        self.connector = get_connector(self.database_name)
        self.connector.restore_dump(input_file)
1331326
private function restoreBackup()
    {
        $hash       = $this->getHash();
        $connection = $this->entityManager->getConnection();

        $this->backupService->restoreBackup($connection, $hash);
    }
246877
public function createBackup()
    {
        $this->output->outputLine();

        if ( !file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) {
            $this->output->outputLine('<b>You don\'t have a keyfile!</b>');
            $this->output->outputLine();
            $this->output->outputLine('Call \'./flow backup:key\' to to generate it.');
            $this->output->outputLine();
            return;
        }

        $this->output->outputLine('<b>Prepare Backup</b>');
        $this->output->outputLine();

        $this->emitBackupStarted();
        $newVersion = time();

        $stats = array(
            'checked' => 0,
            'added' => 0,
            'updated' => 0,
            'removed' => 0,
        );

        $this->collectSystemSettings();

        $this->dumpDatabase();

        foreach ($this->backupFolders as $folderIndex => $folder) {
            $relativeFolder = $this->getPathByFlowRoot($folder);

            $this->output->outputLine('<b>'.($folderIndex+1).'/'.count($this->backupFolders).' Backup '.$relativeFolder.'</b>');
            $this->output->outputLine();
            $this->output->outputLine('Load Backup Versions..');

            $latestFlatBackup = $this->getFlatBackup($folder);
            $newBackupClean = $this->getBackupActions($folder, $newVersion, $latestFlatBackup);
            $stats['checked'] = $stats['checked'] + count($latestFlatBackup);

            if ( count($newBackupClean)>0 ) {
                // encrypt and create backup..
                $this->files->createDirectoryRecursively($this->createDirectoryPath([$this->localBackupTarget, $newVersion, $relativeFolder]));
                $this->output->outputLine('Backup Files..');
                $this->output->progressStart(count($newBackupClean));
                $i = 0;
                foreach ($newBackupClean as $sha1 => $fileItem) {
                    if ($fileItem['action'] == 'add' || $fileItem['action'] == 'update') {
                        if ($fileItem['action'] == 'add') {
                            $stats['added']++;
                        } else {
                            $stats['updated']++;
                        }

                        $this->cryptService->encryptFileToFile(
                            $this->createFilePath([FLOW_PATH_ROOT, $fileItem['file']]),
                            $this->createFilePath([$this->localBackupTarget, $newVersion, $relativeFolder, $sha1 . '.file']));
                        file_put_contents(
                            $this->createFilePath([$this->localBackupTarget, $newVersion, $relativeFolder, $sha1 . '.meta']),
                            json_encode($fileItem));

                    } else {
                        if ($fileItem['action'] == 'remove') {
                            $stats['removed']++;

                            file_put_contents(
                                $this->createFilePath([$this->localBackupTarget, $newVersion, $relativeFolder, $sha1 . '.meta']),
                                json_encode($fileItem));
                        }
                    }
                    $i++;
                    $this->output->progressSet($i);
                }
                $this->output->progressFinish();
                $this->output->outputLine();
            }
        }

        if ( file_exists($this->createDirectoryPath([$this->localBackupTarget, $newVersion])) ) {
            $this->meta['version'] = $newVersion;
            $now = new \DateTime();
            $this->meta['timestamp'] = $now->getTimestamp();
            $this->meta['stats'] = $stats;
            file_put_contents($this->createFilePath([$this->localBackupTarget, $newVersion, 'info.meta']),
                json_encode($this->meta, JSON_PRETTY_PRINT));
        }

        $this->deleteTempFolders();

        $this->removeOldBackups();

        $this->output->outputLine('<b>Backup Finished</b>');
        $this->output->outputLine(' - Checked: '.$stats['checked']);
        $this->output->outputLine(' - Added:   '.$stats['added']);
        $this->output->outputLine(' - Updated: '.$stats['updated']);
        $this->output->outputLine(' - Removed: '.$stats['removed']);
        $this->output->outputLine();
        $this->emitBackupFinished($this->output, $stats);
        return;
    }
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));
  }
498046
public void backupAck(long id, Address from, int topologyId) {
      BaseAckTarget ackTarget = collectorMap.get(id);
      if (ackTarget instanceof SingleKeyCollector) {
         ((SingleKeyCollector) ackTarget).backupAck(topologyId, from);
      } else if (ackTarget instanceof MultiTargetCollectorImpl) {
         ((MultiTargetCollectorImpl) ackTarget).backupAck(topologyId, from);
      }
   }
96998
def mount(device, mountpoint, options=None, persist=False, filesystem="ext3"):
    """"""
    cmd_args = ['mount']
    if options is not None:
        cmd_args.extend(['-o', options])
    cmd_args.extend([device, mountpoint])
    try:
        subprocess.check_output(cmd_args)
    except subprocess.CalledProcessError as e:
        log('Error mounting {} at {}\n{}'.format(device, mountpoint, e.output))
        return False

    if persist:
        return fstab_add(device, mountpoint, filesystem, options=options)
    return True
786080
@Override
    public void backup(long id, long version) {
        if (LOG.isDebugEnabled())
            LOG.debug("Backup: {} ver: {} {}", new Object[]{hex(id), version, copyImmediately ? "(COPY)" : ""});
        if (copyImmediately) {
            currentBackups.put(id, makeBackup(cache.getLine(id), version));
            oldMap().remove(id);
        }
        else
            map.put(id, new BackupEntry(id, version));
    }
1140983
public static void backupFiles(FileSystem fs, File dest, 
      Configuration conf) throws IOException {
    // check if we can still backup
    cleanUpAndCheckBackup(conf, dest);
    
    int MAX_ATTEMPT = 3;
    for (int i = 0; i < MAX_ATTEMPT; i++) {
      try {
        String mdate = dateForm.get().format(new Date(System.currentTimeMillis()));
        if (dest.exists()) {
          File tmp = new File (dest + File.pathSeparator + mdate);
          FLOG.info("Moving aside " + dest + " as " + tmp);
          if (!dest.renameTo(tmp)) {
            throw new IOException("Unable to rename " + dest +
                                  " to " +  tmp);
          }
          FLOG.info("Moved aside " + dest + " as " + tmp);
        }
        return;
      } catch (IOException e) {
        FLOG.error("Creating backup exception. Will retry ", e);
        try {
          Thread.sleep(1000);
        } catch (InterruptedException iex) {
          throw new IOException(iex);
        }
      }
    }
    throw new IOException("Cannot create backup for: " + dest);
  }
51383
private function backup()
    {
        if (! $this->disk->exists(storage_path('langmanGUI'))) {
            $this->disk->makeDirectory(storage_path('langmanGUI'));

            $this->disk->put(storage_path('langmanGUI'.'/.gitignore'), "*\n!.gitignore");
        }

        $this->disk->copyDirectory(resource_path('lang'), storage_path('langmanGUI/'.time()));
    }
303876
def _backup_bytes(target, offset, length):
    
    click.echo('Backup {l} byes at position {offset} on file {file} to .bytes_backup'.format(
        l=length, offset=offset, file=target))

    with open(target, 'r+b') as f:
        f.seek(offset)

        with open(target + '.bytes_backup', 'w+b') as b:
            for _ in xrange(length):
                byte = f.read(1)
                b.write(byte)
            b.flush()

        f.flush()
1118731
void backupConfiguration() throws IOException {

        final String configuration = Constants.CONFIGURATION;

        final File a = new File(installedImage.getAppClientDir(), configuration);
        final File d = new File(installedImage.getDomainDir(), configuration);
        final File s = new File(installedImage.getStandaloneDir(), configuration);

        if (a.exists()) {
            final File ab = new File(configBackup, Constants.APP_CLIENT);
            backupDirectory(a, ab);
        }
        if (d.exists()) {
            final File db = new File(configBackup, Constants.DOMAIN);
            backupDirectory(d, db);
        }
        if (s.exists()) {
            final File sb = new File(configBackup, Constants.STANDALONE);
            backupDirectory(s, sb);
        }

    }
1335805
def _backup_pb_gui(self, dirs):
        """"""
        import PySimpleGUI as sg
        # Legacy support
        with ZipFile(self.zip_filename, 'w') as backup_zip:
            for count, path in enumerate(dirs):
                backup_zip.write(path, path[len(self.source):len(path)])
                if not sg.OneLineProgressMeter('Writing Zip Files', count + 1, len(dirs) - 1, 'Files'):
                    break