yandex.php 962 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use AutoBackup\Exception\ProviderException;
  3. use AutoBackup\ProviderOptions;
  4. use AutoBackup\Providers\Yandex;
  5. require_once "vendor/autoload.php";
  6. /** Configuration */
  7. $directoryWithFilesMaskToScan = "www/files-to/backup/*.file.tar.*";
  8. $baseRemoteDirectoryPath = "/backups/";
  9. $token = "";
  10. $FILES_CMD = "ls $directoryWithFilesMaskToScan";
  11. $result = shell_exec($FILES_CMD);
  12. $arrayFiles = explode("\n", $result);
  13. $resultFiles = [];
  14. foreach ($arrayFiles as $index => $arrayFile) {
  15. if (!empty($arrayFile)) {
  16. $resultFiles[] = $arrayFile;
  17. }
  18. }
  19. $options = new ProviderOptions\Yandex();
  20. $options->token = $token;
  21. $options->remoteDirectoryPath = $baseRemoteDirectoryPath;
  22. $options->fileWebPath = "https://your.site.there/backups/there/";
  23. $options->backupVersionDirName = date("Y-m-d");
  24. $yandexProvider = new Yandex($options);
  25. try {
  26. $yandexProvider->proceedBackup($resultFiles);
  27. } catch (ProviderException $e) {
  28. echo $e->getMessage();
  29. }