Download files from yandex disk. Use for backup.
- yadisk
- Reg app and create debug token for apps in ya.disk ( https://yandex.ru/dev/oauth/doc/dg/tasks/get-oauth-token-docpage/ )
- run script with params
--token <TOKEN>
or create ENVIRONTOKEN=<TOKEN>
- List the directory to download (backup) after the flag
--dirs
otherwise will try to download the default directory
Param | Description | Default |
---|---|---|
--token |
token to connect ya.disk. For create lookup ( https://yandex.ru/dev/oauth/doc/dg/tasks/get-oauth-token-docpage/) | None |
--dirs |
folder to download (backup) | backup |
--no-archive |
flag for canceling archiving after downloading | False |
-l --logs |
Path to save log file. | None |
--timeout |
timeout in seconds for all. Defaults to 10 seconds. | 10 |
--retry |
retry connection. Defaults to 3 attempts | 3 |
--path-to-download |
locate file (__file__ ) |
|
--delete-old |
delete all archives in the path-to-download after downloading from y.disk and before compressing |
False |
Download file from folder Catalog
and Catalog 2
python backup.py --token My_secret_token --dirs Catalog Catalog2
for backup every month
BASE_DIR=/opt/backup-ya-disk/YaDiskDownloader/backup
LANG=ru_RU.UTF-8
0 0 1 * * source /opt/backup-ya-disk/YaDiskDownloader/venv/bin/activate ; python3 /opt/backup-ya-disk/YaDiskDownloader/backup.py --token SECRET_TOKEN_FROM_YANDEX --dirs "catalog" "catalog 2" --path-to-download {$BASE_DIR} --timeout 101```