yandex.php 920 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 = "/home/bitrix/www/bitrix/backup/*.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. $yandexProvider = new Yandex($options);
  24. try {
  25. $yandexProvider->proceedBackup($resultFiles);
  26. } catch (ProviderException $e) {
  27. echo $e->getMessage();
  28. }