Skip to content

Toliak/YandexDiskRSync

Repository files navigation

Yandex Disk RSync

Yandex Disk RSync is the app that provides minimalistic CLI interface for local and Yandex Disk storage synchronization.

The application is the wrapper over ydcmd project and uses its SDK.

Requirements

  • OS Windows / Linux / macOS
  • Python 3.7 or above

Installation

Linux / macOS into global scope

# 1. Clone the repository into the temporary directory
cd /tmp
git clone https://github.com/Toliak/YandexDiskRSync

# 2. Install the application
cd YandexDiskRSync
python setup.py install

# 3. Add startup script
YDR_PATH=$( python -c "import yandex_disk_rsync; print(yandex_disk_rsync.__path__[0])" )
cat > /usr/local/bin/ydsync <<EOF
#! /bin/sh
exec python "$YDR_PATH" "\$@"
EOF
chmod 755 /usr/local/bin/ydsync

# 4. Test the app
ydsync -h

Linux / macOS with local scope (+venv)

# 1. Clone the repository
cd $HOME/.local/share/
git clone https://github.com/Toliak/YandexDiskRSync
cd YandexDiskRSync

# 2. Initialize venv and install requirements
python -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
python setup.py build
deactivate

# 3. Add startup script
cat > $HOME/.local/bin/ydsync <<EOF
#! /bin/sh
exec $HOME/.local/share/YandexDiskRSync/ydsync "\$@"
EOF
chmod 755 $HOME/.local/bin/ydsync

# 4. Test the app
ydsync -h

Windows

# 1. Clone the repository
New-Item -Type Directory -ErrorAction Ignore $HOME\AppData\Local\Programs
Set-Location $HOME\AppData\Local\Programs
git clone https://github.com/Toliak/YandexDiskRSync
Set-Location ./YandexDiskRSync

# 2. Initialize venv and install requirements
python -m venv venv
& .\venv\Scripts\Activate.ps1
pip install -r .\requirements.txt
python setup.py build
deactivate

# 3. Add startup script
New-Item -Type File -ErrorAction Ignore $PROFILE
Add-Content $PROFILE "function ydsync() { $PWD\ydsync.ps1 `@args }`n"

# 4. Restart powershell and test the app
ydsync -h

Configuration

The application configuration stored in the YAML format.

Configuration file yandex_disk_rsync.yaml possible locations:

  • The file in the current directory ($PWD/yandex_disk_rsync.yaml)
  • The hidden file (named .yandex_disk_rsync.yaml) in the current directory
  • The hidden file in the user's home directory ($HOME/.yandex_disk_rsync.yaml)

Required configuration field is token. Token creation guide described here.

Example:

ydcmd:
    token: __YOUR_TOKEN_HERE__
    verbose: true
    debug: true
    retries: 2
    progress: true

sync:
    local_path: __CAN_BE_DEFINED_HERE_OR_IN_ARGUMENTS__
    yd_path: __CAN_BE_DEFINED_HERE_OR_IN_ARGUMENTS__
    delete: __CAN_BE_DEFINED_HERE_OR_IN_ARGUMENTS__

Full configuration description located at the ydcmd README.

Default configuration described in the source code.

Usage

usage: yandex_disk_rsync [-h] [--config CONFIG] [--local-path LOCAL_PATH]
                         [--yd-path YD_PATH] --target {disk,local} [--delete]

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG, -c CONFIG
  --local-path LOCAL_PATH, -l LOCAL_PATH
  --yd-path YD_PATH, -d YD_PATH
  --target {disk,local}, -t {disk,local}
                        Target, the synchronization destination (editable)
  --delete              Can delete files

Target option specifies the target location of data flow: local or disk storage. If the local is chosen, the files synchronized from disk into local.

Case Target is local Target is disk
No file in local Download from disk Delete* from disk
No file in disk Delete* from local Upload to disk
File checksum mismatch Download from disk Upload to disk
Same file No changes No changes

* works only if delete argument has been passed or is True.

After preparing changes summary, the app will print them and ask a user for confirmation.

2022-11-13 13:17:29,406 - YandexDiskRSync - INFO - Collected 31 remote files (__init__.py:258)
2022-11-13 13:17:29,407 - YandexDiskRSync - INFO - =========   Not in local    ========= (__init__.py:278)
2022-11-13 13:17:29,407 - YandexDiskRSync - INFO - =========   Not in remote   ========= (__init__.py:281)
2022-11-13 13:17:29,407 - YandexDiskRSync - INFO - [ + ] new_dir/test_file (__init__.py:112)
2022-11-13 13:17:29,407 - YandexDiskRSync - INFO - ------------------------------------- (__init__.py:284)
Continue? [y/n]

Known issues

CA file

Windows users may be concerned with the HTTPS CA problem. The solution is:

  1. Download GlobalSign CA certificate
  2. Specify ca-file with path to the certificate in the configuration file

About

Synchronization of the specified directories in Yandex Disk (yadisk) and the local PC

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published