Giter Site home page Giter Site logo

iceisnicehq / yandexdiskrsync Goto Github PK

View Code? Open in Web Editor NEW

This project forked from toliak/yandexdiskrsync

0.0 0.0 0.0 40 KB

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

Shell 0.62% Python 97.44% PowerShell 1.14% Dockerfile 0.80%

yandexdiskrsync's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.