Look up basebackups from the object store, prune any extra
        backups and return the datetime of the latest backup.
495632
def check_backup_count_and_state(self, site):
        """"""
        basebackups = self.get_remote_basebackups_info(site)
        self.log.debug("Found %r basebackups", basebackups)

        if basebackups:
            last_backup_time = basebackups[-1]["metadata"]["start-time"]
        else:
            last_backup_time = None

        allowed_basebackup_count = self.config["backup_sites"][site]["basebackup_count"]
        if allowed_basebackup_count is None:
            allowed_basebackup_count = len(basebackups)

        while len(basebackups) > allowed_basebackup_count:
            self.log.warning("Too many basebackups: %d > %d, %r, starting to get rid of %r",
                             len(basebackups), allowed_basebackup_count, basebackups, basebackups[0]["name"])
            basebackup_to_be_deleted = basebackups.pop(0)
            pg_version = basebackup_to_be_deleted["metadata"].get("pg-version")
            last_wal_segment_still_needed = 0
            if basebackups:
                last_wal_segment_still_needed = basebackups[0]["metadata"]["start-wal-segment"]

            if last_wal_segment_still_needed:
                self.delete_remote_wal_before(last_wal_segment_still_needed, site, pg_version)
            self.delete_remote_basebackup(site, basebackup_to_be_deleted["name"], basebackup_to_be_deleted["metadata"])
        self.state["backup_sites"][site]["basebackups"] = basebackups

        return last_backup_time
315457
def _get_timestamp(self):
        """"""
        filename_date = _find_date(os.path.basename(self._path))
        if filename_date:
            return filename_date
1317984
def list_backups
      data = DataTable._get_dyn_table(self, '/data/admin/backups?tableID=BackupSynopsis')
      data.map { |b| Backup.parse(b) }
    end
1306374
def get_last_modified_date(
            self,
            bucket: str,
            key: str,
    ) -> datetime.datetime:
        
        blob_obj = self._get_blob_obj(bucket, key)
        return blob_obj.updated
769932
def _backup_previous_version(func: Callable = None):
    """"""

    @wraps(func)
    def wrapper(self, *args, **kwargs):
        self.old_path = None
        if self.is_local:
            self.old_path = join(gettempdir(), self.name)
            if exists(self.old_path):
                rmtree(self.old_path)
            shutil.copytree(self.path, self.old_path)
        try:
            func(self, *args, **kwargs)

        # Modified skill or GitError should not restore working copy
        except (SkillModified, GitError, GitException):
            raise
        except Exception:
            LOG.info('Problem performing action. Restoring skill to '
                     'previous state...')
            if exists(self.path):
                rmtree(self.path)
            if self.old_path and exists(self.old_path):
                shutil.copytree(self.old_path, self.path)
            self.is_local = exists(self.path)
            raise

    return wrapper
485022
function getLastKnownUpdatedAt() {
        
        return Platform.async(function(callback) {
            callback();
        })().then(function() {
            
            if (pullQueryId) { // read lastKnownUpdatedAt from the store
                return store.lookup(pulltimeTableName, pullQueryId, true /* suppressRecordNotFoundError */);
            }

        }).then(function(result) {

            if (result) {
                return result.value;
            }

            return new Date (1970, 0, 0);
        });
    }
1322276
public function moveOldBackup()
    {
        Service::$log->msg('Filesystem: moving old backups');
        // remove the 2-day file
        if(file_exists($this->storagePath.'backup-2days-old')){
            unlink($this->storagePath.'backup-2days-old');
        }

        // copy current 1-day file to 2-day
        $sourceFile = $this->storagePath . 'backup-1day-old';
        $destinationFile = $this->storagePath . 'backup-2days-old';
        if (file_exists($sourceFile)) {
            copy($sourceFile, $destinationFile);
        }

        // remove the old 1-day file
        $destinationFileTemp = $this->storagePath. 'backup-1day-old';
        if (file_exists($destinationFileTemp)) {
            unlink($destinationFileTemp);
        }

        Service::$log->msg('Filesystem: moving old backups done');

        return $destinationFile;
    }
12384
def getUpdated(self, sObjectType, startDate, endDate):
    '''
    
    '''
    self._setHeaders('getUpdated')
    return self._sforce.service.getUpdated(sObjectType, startDate, endDate)
716263
private void restoreBackup() {

        if (incBackup) {
            restoreBackupIncremental();

            return;
        }

        // in case data file cannot be deleted, reset it
        DataFileCache.deleteOrResetFreePos(database, fileName + ".data");

        try {
            FileArchiver.unarchive(fileName + ".backup", fileName + ".data",
                                   database.getFileAccess(),
                                   FileArchiver.COMPRESSION_ZIP);
        } catch (Exception e) {
            throw Error.error(ErrorCode.FILE_IO_ERROR,
                              ErrorCode.M_Message_Pair, new Object[] {
                fileName + ".backup", e.toString()
            });
        }
    }
90784
private void removeOldBackups(long daysToKeep) {

        long maxAge = (System.currentTimeMillis() - (daysToKeep * 24 * 60 * 60 * 1000));
        File[] files = m_backupFolder.listFiles();
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            long lastMod = file.lastModified();
            if ((lastMod < maxAge) & (!file.getAbsolutePath().endsWith(CmsConfigurationManager.POSTFIX_ORI))) {
                file.delete();
                if (LOG.isDebugEnabled()) {
                    LOG.debug(
                        Messages.get().getBundle().key(Messages.LOG_REMOVE_CONFIG_FILE_1, file.getAbsolutePath()));
                }
            }
        }
    }
33515
private void cleanStaleFiles(File backupDir, AsyncOperationStatus status) {
        String[] filesInEnv = env.getHome().list();
        String[] filesInBackupDir = backupDir.list();
        if(filesInEnv != null && filesInBackupDir != null) {
            HashSet<String> envFileSet = new HashSet<String>();
            for(String file: filesInEnv)
                envFileSet.add(file);
            // delete all files in backup which are currently not in environment
            for(String file: filesInBackupDir) {
                if(file.endsWith(BDB_EXT) && !envFileSet.contains(file)) {
                    status.setStatus("Deleting stale jdb file :" + file);
                    File staleJdbFile = new File(backupDir, file);
                    staleJdbFile.delete();
                }
            }
        }
    }
671783
def only_newer(copy_func):
    
    @functools.wraps(copy_func)
    def wrapper(src, dst, *args, **kwargs):
        is_newer_dst = (
            dst.exists()
            and dst.getmtime() >= src.getmtime()
        )
        if is_newer_dst:
            return dst
        return copy_func(src, dst, *args, **kwargs)
    return wrapper
1287259
def backup_db():
    
    if not os.path.exists('backups'):
        os.makedirs('backups')
    local('python manage.py dump_database | gzip > backups/' + _sql_paths('local', datetime.now()))
788679
private long getLastModifiedTime(List<?> fileLists) {
    long lastModified = 0;

    for (Object entry : fileLists) {
      if (entry instanceof FileList) {
        FileList list = (FileList) entry;

        for (String fileName : list.getFiles(this.getProject())) {
          File path = list.getDir(this.getProject());
          File file = new File(path, fileName);
          lastModified = Math.max(getLastModifiedTime(file), lastModified);
        }
      } else if (entry instanceof Path) {
        Path path = (Path) entry;
        for (String src : path.list()) {
          File file = new File(src);
          lastModified = Math.max(getLastModifiedTime(file), lastModified);
        }
      }
    }

    return lastModified;
  }
1280887
void backup() throws ConfigurationPersistenceException {
        if (!doneBootup.get()) {
            return;
        }
        try {
            if (!interactionPolicy.isReadOnly()) {
                //Move the main file to the versioned history
                moveFile(mainFile, getVersionedFile(mainFile));
            } else {
                //Copy the Last file to the versioned history
                moveFile(lastFile, getVersionedFile(mainFile));
            }
            int seq = sequence.get();
            // delete unwanted backup files
            int currentHistoryLength = getInteger(CURRENT_HISTORY_LENGTH_PROPERTY, CURRENT_HISTORY_LENGTH, 0);
            if (seq > currentHistoryLength) {
                for (int k = seq - currentHistoryLength; k > 0; k--) {
                    File delete = getVersionedFile(mainFile, k);
                    if (! delete.exists()) {
                        break;
                    }
                    delete.delete();
                }
            }
        } catch (IOException e) {
            throw ControllerLogger.ROOT_LOGGER.failedToBackup(e, mainFile);
        }
    }
303788
def last_updated(self):
        '''
        
        '''
        derived_path = self.context.request.url
        timestamp_key = self.timestamp_key_for(derived_path)

        if self.exists(self.timestamp_key_for, derived_path):
            return self.storage.get(timestamp_key)

        return None
764880
private void addBackup() {
        // move the current log file to the newly formatted backup name
        String newname = this.fileinfo + this.myFormat.format(new Date(HttpDispatcher.getApproxTime())) + this.extensioninfo;
        File newFile = new File(newname);
        renameFile(this.myFile, newFile);
        // now see if we need to delete an existing backup to make room
        if (this.backups.size() == getMaximumBackupFiles()) {
            File oldest = this.backups.removeLast();
            if (null != oldest && oldest.exists()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, getFileName() + ": Purging oldest backup-> " + oldest.getName());
                }
                oldest.delete();
            }
        }
        this.backups.addFirst(newFile);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, getFileName() + ": number of backup files-> " + this.backups.size());
        }
    }