Returns an array of backups
@return array
5756
protected function getListBackup()
    {
        $options = $this->query_filter;
        $options['limit'] = $this->data_limit;
        return $this->backup->getList($options);
    }
1185240
public function listZips(): array {

        return array_column(
            array_map(function($key, $archive) {
                return [ "key" => $key, "file" => $archive->getZipFile() ];
            }, array_keys($this->zip_archives), $this->zip_archives),
        "file", "key");

    }
927019
protected function getFileSystem(): array
	{
		$fileSystem = [];

		$command = $this->readCommand('df -T');
		if ($command) {
			$bufe = preg_split("/\n/", $command, -1, PREG_SPLIT_NO_EMPTY);
			unset($bufe[0]);
			foreach ($bufe as $buf) {
				$data = preg_split('/\s+/', $buf);
				$mounted = new Obj;

				$mounted->partition = $data[0];
				$mounted->type = $data[1];
				$mounted->size = $data[2] * 1024;
				$mounted->used = $data[3] * 1024;
				$mounted->free = $data[4] * 1024;
				$mounted->usage = $data[5];
				$mounted->mountPoint = $data[6];

				$fileSystem[] = $mounted;
			}
		}

		return $fileSystem;
	}
1327460
private function getFiles(): array
	{
		$result = [];
		$files = Finder::find('*')
			->in($this->getFullPath());
		foreach ($files as $file) {
			$result[] = new FileInfo($file);
		}
		usort($result, function ($a, $b) {
			if ($a->isDir == $b->isDir) {
				return strcmp($a->name, $b->name);
			} else {
				if ($a->isDir) {
					return -1;
				} else {
					return 1;
				}
			}
		});
		return $result;
	}
89203
protected function backupComposer()
    {
        $composerDir = $this->composer->getVendorDirectory() . '/composer';
        $composerBak = $composerDir . '.bak';

        // Remove old backup folder.
        if (is_dir($composerBak)) {
            $process = new Process('rm -rf "' . $composerBak . '"');
            $process->run();
            $isSuccessful = $process->isSuccessful();

            unset($process);

            if (!$isSuccessful) {
                return false;
            }
        }

        // Backup
        $process = new Process('cp -R "' . $composerDir . '" "' . $composerBak . '"');
        $process->run();
        $isSuccessful = $process->isSuccessful();

        unset($process);

        return $isSuccessful;
    }
1016131
public function getLastBackupTime()
    {
        $backups = $this->listBackups();
        if (is_array($backups)) {
            if (!empty($backups)) {
                $timestamp = $backups[0]->timestamp;

                return $timestamp;
            }

            return 'There is no backup available.';
        }

        return $backups;
    }
1288525
public function getFiles() : array
    {
        if(!$this->_isLoaded) {
            $this->load();
        }

        return array_map(function($file) {
            return new File($this->getPath(). DIRECTORY_SEPARATOR .$file);
        }, $this->_files);
    }
732111
public function createBackup()
    {
        try {
            // compressor instance
            $compressor = new Compress('backup-' . date('Y-m-d_H-i-s'), $this->backupConfig->TempPath);

            // first we need to export all the databases
            $backupMongo = new BackupMongo($this->backupConfig->get('MongoDatabases', [], true), $this->backupConfig->TempPath);
            $compressor->addSources($backupMongo->exportDatabases());

            // add folders to the compressor
            $compressor->addSources($this->backupConfig->get('Folders', [], true));

            // compress all the folders and database exports in one archive
            $backupArchive = $compressor->compress();

            // encrypt the archive -> only if passpharse is set
            $encryptionStatus = false;
            if ($this->backupConfig->get('Encryption', false)) {
                $encryption = new Encrypt($backupArchive, $this->backupConfig->Encryption, $this->backupConfig->TempPath);
                $encArchive = $encryption->encrypt();
                $encryptionStatus = true;
            } else {
                $encArchive = $backupArchive;
            }

            $backupSize = filesize($encArchive);

            // check if we should backup to S3
            if ($this->backupConfig->get('S3', false)) {
                $s3 = new Lib\S3($this->backupConfig->get('S3'));

                // move the old 1-day backup to 2-day backup
                $oldBackup = $s3->moveOldBackup();
                $this->backupsCreated['s3']['48h'] = [
                    'filename'  => $oldBackup,
                    'encrypted' => $encryptionStatus
                ];
                

                // create new 1 day backup
                $uploadedFile = $s3->upload($encArchive, 'backup-1day-old');
                $this->backupsCreated['s3']['24h'] = [
                    'size'      => $backupSize,
                    'filename'  => $uploadedFile,
                    'encrypted' => $encryptionStatus
                ];

                // check if we need 7-day backup and 30-day backup
                $frequencies = $this->backupConfig->get('Frequency', [], true);

                // week
                // we always do weekly backups on sunday
                if (in_array('Week', $frequencies) && date('w') == '0') {
                    $s3->deleteBackup('backup-week');
                    $copiedFile = $s3->copyLatestBackup('backup-week');
                    $this->backupsCreated['s3']['weekly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }

                // month
                // we always do monthly backups on the last day of the month
                if (in_array('Month', $frequencies) && date('d') == date('t')) {
                    $s3->deleteBackup('backup-month');
                    $copiedFile = $s3->copyLatestBackup('backup-month');
                    $this->backupsCreated['s3']['monthly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }

                // year
                // we always do monthly backups on the last day of the year
                if (in_array('Year', $frequencies) && date('d.m') == '31.12') {
                    $s3->deleteBackup('backup-year');
                    $copiedFile = $s3->copyLatestBackup('backup-year');
                    $this->backupsCreated['s3']['yearly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }
            }

            // check if a file system backup is required
            if ($this->backupConfig->get('BackupStoragePath', false)) {
                $fsBackup = new Lib\Filesystem($this->backupConfig->get('BackupStoragePath'));

                // move the old 1-day backup to 2-day backup
                $oldBackup = $fsBackup->moveOldBackup();
                $this->backupsCreated['local']['48h'] = [
                    'filename'  => $oldBackup,
                    'encrypted' => $encryptionStatus
                ];

                // create new 1 day backup
                $uploadedFile = $fsBackup->upload($encArchive, 'backup-1day-old');
                $this->backupsCreated['local']['24h'] = [
                    'size'      => $backupSize,
                    'filename'  => $uploadedFile,
                    'encrypted' => $encryptionStatus
                ];

                // check if we need 7-day backup and 30-day backup
                $frequencies = $this->backupConfig->get('Frequency', [], true);

                // week
                // we always do weekly backups on sunday
                if (in_array('Week', $frequencies) && date('w') == '0') {
                    $fsBackup->deleteBackup('backup-week');
                    $copiedFile = $fsBackup->copyLatestBackup('backup-week');
                    $this->backupsCreated['local']['weekly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }

                // month
                // we always do monthly backups on the last day of the month
                if (in_array('Month', $frequencies) && date('d') == date('t')) {
                    $fsBackup->deleteBackup('backup-month');
                    $copiedFile = $fsBackup->copyLatestBackup('backup-month');
                    $this->backupsCreated['local']['monthly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }

                // year
                // we always do monthly backups on the last day of the year
                if (in_array('Year', $frequencies) && date('d.m') == '31.12') {
                    $fsBackup->deleteBackup('backup-year');
                    $copiedFile = $fsBackup->copyLatestBackup('backup-year');
                    $this->backupsCreated['local']['yearly'] = [
                        'size'      => $backupSize,
                        'filename'  => $copiedFile,
                        'encrypted' => $encryptionStatus
                    ];
                }
            }

            // do the cleanup
            Cleanup::doCleanup();

            // end log
            self::$log->msg('Backup ended');
            self::$log->msg('Execution time: ' . $this->getExecutionTime());

            // set success flag
            $this->isSuccessful = true;

            if ($this->storeLog) {
                self::$log->writeLog();
            } else {
                return self::$log->getLog();
            }

        } catch (\Exception $e) {
            // set success flag
            $this->isSuccessful = false;

            self::$log->msg('ERROR: ' . $e->getMessage());
            if ($this->storeLog) {
                self::$log->writeLog();
            } else {
                return self::$log->getLog();
            }
        }
    }
1351103
public function toArray()
    {
        $result = parent::toArray();

        $result['hasFile'] = false;

        if ($this->getFileNameFromReport()) {
            /** @var Directory $queueStorage */
            $queueStorage = $this->fileSystemService
                ->getDirectory(QueueDispatcherInterface::FILE_SYSTEM_ID);

            if ($queueStorage->getFile($this->getFileNameFromReport())->exists()) {
                $result['hasFile'] = true;
            }
        }

        return $result;
    }
1109269
public function index()
    {
        $backups = collection($this->BackupManager->index())
            ->map(function (Entity $backup) {
                return $backup->set('slug', urlencode($backup->filename));
            });

        $this->set(compact('backups'));
    }
879784
protected function newV1BackupSeed() {
        list($backupMnemonic, $backupSeed, $backupPrivateKey) = $this->generateNewSeed("");

        return [$backupMnemonic, $backupSeed, $backupPrivateKey];
    }
255078
protected function getDeltasFilesArray()
    {
        $files = [];

        $baseDir = realpath($this->dir);
        $dh = opendir($baseDir);

        if ($dh === false) {
            return $files;
        }

        $fileChangeNumberPrefix = '';
        while (($file = readdir($dh)) !== false) {
            if (preg_match('[\d+]', $file, $fileChangeNumberPrefix)) {
                $files[(int) $fileChangeNumberPrefix[0]] = $file;
            }
        }

        return $files;
    }
883080
public function folderContent()
    {
        $result = [];
        $path = $this->ensureUserPath($this->blob->path);

        $list = collect($this->storage->getDriver()->listContents($path))
            ->pluck('path');

        $exclude = (new ThumbService($this->package))->getSizes()->all();
        $isExcluded = function ($path) use ($exclude) {
            $parts = explode('/', Str::normalizePath($path));
            if (count($parts) > 0) {
                return array_key_exists($parts[0], $exclude);
            }

            return false;
        };

        $list->each(function ($glob) use (&$result, $isExcluded) {
            if ($isExcluded($glob)) {
                // skip any thumbs dir and do not show it for users
                return;
            }

            $result[] = (new Blob($this->package))
                ->setPath($glob)
                ->fullDetails();
        });

        return $result;
    }
355618
public function getFilesArray()
    {
        if ($this->_filesArray === null) {
            $this->_filesArray = $this->getQueryCacheHelper((new Query())->from('{{%admin_storage_file}}')->select(['id', 'is_hidden', 'is_deleted', 'folder_id', 'name_original', 'name_new', 'name_new_compound', 'mime_type', 'extension', 'hash_name', 'hash_file', 'upload_timestamp', 'file_size', 'upload_user_id', 'caption'])->indexBy('id'), self::CACHE_KEY_FILE);
        }

        return $this->_filesArray;
    }
448551
public function sync()
    {
        $this->backup();

        $output = [];

        $translations = $this->getTranslations();

        $keysFromFiles = array_collapse($this->getTranslationsFromFiles());

        foreach (array_unique($keysFromFiles) as $fileName => $key) {
            foreach ($translations as $lang => $keys) {
                if (! array_key_exists($key, $keys)) {
                    $output[] = $key;
                }
            }
        }

        return array_values(array_unique($output));
    }
162957
private function dumpFiles()
    {
        $files = [];

        foreach(File::allFiles(Config::dumpPath()) as $dumpFile) {
            $files[] = $dumpFile->getRealpath();
        }

        sort($files);

        return $files;
    }
428257
public function store() : array //check whether this method is required, otherwise, we have to rename to delte
	{
		$this->validate();

		if ($this->files()->isEmpty()) {
			return [];
		}

		return $this->files()->flatMap(function ($item) {
			$files[] = ['path' => $item->store($this->directory)];
			return $files;
		})->all();
	}