Dropbox_uploader 详细参数及命令说明

# Dropbox Uploader

Dropbox Uploader is a **BASH** script which can be used to upload, download, delete, list files (and more!) from **Dropbox**, an online file sharing, synchronization and backup service.

It's written in BASH scripting language and only needs **cURL**.

You can take a look to the [GiHub project page](https://github.com/andreafabrizi/Dropbox-Uploader).

**Why use this script?**

* **Portable:** It's written in BASH scripting and only needs `cURL` (curl is a tool to transfer data from or to a server, available for all operating systems and installed by default in many linux distributions).

* **Secure:** It's not required to provide your username/password to this script, because it uses the official Dropbox API v2 for the authentication process.

Please refer to the [Wiki](https://github.com/andreafabrizi/Dropbox-Uploader/wiki) for tips and additional information about this project. The Wiki is also the place where you can share your scripts and examples related to Dropbox Uploader.

## Features

* Cross platform

* Support for the official Dropbox API v2

* No password required or stored

* Simple step-by-step configuration wizard

* Simple and chunked file upload

* File and recursive directory download

* File and recursive directory upload

* Shell wildcard expansion (only for upload)

* Delete/Move/Rename/Copy/List/Share files

* Create share link

* Monitor for changes

## Getting started

First, clone the repository using git (recommended):

```bash

git clone https://github.com/andreafabrizi/Dropbox-Uploader.git

```

or download the script manually using this command:

```bash

curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh

```

Then give the execution permission to the script and run it:

```bash

$chmod +x dropbox_uploader.sh

$./dropbox_uploader.sh

```

The first time you run `dropbox_uploader`, you'll be guided through a wizard in order to configure access to your Dropbox. This configuration will be stored in `~/.dropbox_uploader`.

## Usage

The syntax is quite simple:

```

./dropbox_uploader.sh [PARAMETERS] COMMAND...

[%%]: Optional param

<%%>: Required param

```

**Available commands:**

* **upload** &lt;LOCAL_FILE/DIR ...&gt; &lt;REMOTE_FILE/DIR&gt;

Upload a local file or directory to a remote Dropbox folder.

If the file is bigger than 150Mb the file is uploaded using small chunks (default 50Mb);

in this case a . (dot) is printed for every chunk successfully uploaded and a * (star) if an error

occurs (the upload is retried for a maximum of three times).

Only if the file is smaller than 150Mb, the standard upload API is used, and if the -p option is specified

the default curl progress bar is displayed during the upload process.

The local file/dir parameter supports wildcards expansion.

* **download** &lt;REMOTE_FILE/DIR&gt; [LOCAL_FILE/DIR]

Download file or directory from Dropbox to a local folder

* **delete** &lt;REMOTE_FILE/DIR&gt;

Remove a remote file or directory from Dropbox

* **move** &lt;REMOTE_FILE/DIR&gt; &lt;REMOTE_FILE/DIR&gt;

Move or rename a remote file or directory

* **copy** &lt;REMOTE_FILE/DIR&gt; &lt;REMOTE_FILE/DIR&gt;

Copy a remote file or directory

* **mkdir** &lt;REMOTE_DIR&gt;

Create a remote directory on Dropbox

* **list** [REMOTE_DIR]

List the contents of the remote Dropbox folder

* **monitor** [REMOTE_DIR] [TIMEOUT]

Monitor the remote Dropbox folder for changes. If timeout is specified, at the first change event the function will return.

* **share** &lt;REMOTE_FILE&gt;

Get a public share link for the specified file or directory

* **saveurl** &lt;URL&gt; &lt;REMOTE_DIR&gt;

Download a file from an URL to a Dropbox folder directly (the file is NOT downloaded locally)

* **search** &lt;QUERY&gt;

Search for a specific pattern on Dropbox and returns the list of matching files or directories

* **info**

Print some info about your Dropbox account

* **space**

Print some info about the space usage on your Dropbox account

* **unlink**

Unlink the script from your Dropbox account

**Optional parameters:**

* **-f &lt;FILENAME&gt;**

Load the configuration file from a specific file

* **-s**

Skip already existing files when download/upload. Default: Overwrite

* **-d**

Enable DEBUG mode

* **-q**

Quiet mode. Don't show progress meter or messages

* **-h**

Show file sizes in human readable format

* **-p**

Show cURL progress meter

* **-k**

Doesn't check for SSL certificates (insecure)

* **-x &lt;FILENAME&gt;**

Ignores/excludes directories or files from syncing.

-x filename -x directoryname.

**Examples:**

```bash

    ./dropbox_uploader.sh upload /etc/passwd /myfiles/passwd.old

    ./dropbox_uploader.sh upload *.zip /

    ./dropbox_uploader.sh -x .git upload ./project /

    ./dropbox_uploader.sh download /backup.zip

    ./dropbox_uploader.sh delete /backup.zip

    ./dropbox_uploader.sh mkdir /myDir/

    ./dropbox_uploader.sh upload "My File.txt" "My File 2.txt"

    ./dropbox_uploader.sh share "My File.txt"

    ./dropbox_uploader.sh list

```

## Tested Environments

* GNU Linux

* FreeBSD 8.3/10.0

* MacOSX

* Windows/Cygwin

* Raspberry Pi

* QNAP

* iOS

* OpenWRT

* Chrome OS

* OpenBSD

* Termux

If you have successfully tested this script on others systems or platforms please let me know!

## Running as cron job

Dropbox Uploader relies on a different configuration file for each system user. The default configuration file location is `$HOME/.dropbox_uploader`. This means that if you setup the script with your user and then you try to run a cron job as root, it won't work.

So, when running this script using cron, please keep in mind the following:

* Remember to setup the script with the user used to run the cron job

* Always specify the full script path when running it (e.g.  /path/to/dropbox_uploader.sh)

* Use always the -f option to specify the full configuration file path, because sometimes in the cron environment the home folder path is not detected correctly (e.g. -f /home/youruser/.dropbox_uploader)

* My advice is, for security reasons, to not share the same configuration file with different users

## How to setup a proxy

To use a proxy server, just set the **https_proxy** environment variable:

**Linux:**

```bash

    export HTTP_PROXY_USER=XXXX

    export HTTP_PROXY_PASSWORD=YYYY

    export https_proxy=http://192.168.0.1:8080

```

**BSD:**

```bash

    setenv HTTP_PROXY_USER XXXX

    setenv HTTP_PROXY_PASSWORD YYYY

    setenv https_proxy http://192.168.0.1:8080

```

## BASH and Curl installation

**Debian & Ubuntu Linux:**

```bash

    sudo apt-get install bash (Probably BASH is already installed on your system)

    sudo apt-get install curl

```

**BSD:**

```bash

    cd /usr/ports/shells/bash && make install clean

    cd /usr/ports/ftp/curl && make install clean

```

**Cygwin:**

You need to install these packages:

* curl

* ca-certificates

* dos2unix

Before running the script, you need to convert it using the dos2unix command.

**Build cURL from source:**

* Download the source tarball from http://curl.haxx.se/download.html

* Follow the INSTALL instructions

## DropShell

DropShell is an interactive DropBox shell, based on DropBox Uploader:

```bash

DropShell v0.2

The Intractive Dropbox SHELL

Andrea Fabrizi - andrea.fabrizi@gmail.com

Type help for the list of the available commands.

andrea@Dropbox:/$ ls

[D] 0      Apps

[D] 0      Camera Uploads

[D] 0      Public

[D] 0      scripts

[D] 0      Security

[F] 105843  notes.txt

andrea@DropBox:/ServerBackup$ get notes.txt

```

## Running as Docker Container

First build the docker image:

```bash

docker build https://github.com/sircuri/Dropbox-Uploader.git -f Dockerfile -t <TAG>

```

or for RaspBerry:

```bash

docker build https://github.com/sircuri/Dropbox-Uploader.git -f Dockerfile.pi -t <TAG>

```

then, you can run it as following:

```bash

docker run -i --rm --user=$(id -u):$(id -g) -v <LOCAL_CONFIG_PATH>:/config -v <YOUR_DATA_DIR_MOUNT>:/workdir <TAG> <Arguments>

```

This will store the auth token information in the given local directory in `<LOCAL_CONFIG_PATH>`. To ensure access to your mounted directories it can be important to pass a UID and GID to the docker deamon (as stated in the example by the --user argument)

Using the script with docker makes it also possible to run the script even on windows machines.

To use a proxy, just set the mentioned environment variables via the docker `-e` parameter.

## Related projects

[thunar-dropbox](https://github.com/mDfRg/Thunar-Dropbox-Uploader-plugin/tree/thunar-dropbox/plugins/thunar): A simple extension to Dropbox Uploader that provides a convenient method to share your Dropbox files with one click!

## Donations

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,634评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,951评论 3 391
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 161,427评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,770评论 1 290
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,835评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,799评论 1 294
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,768评论 3 416
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,544评论 0 271
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,979评论 1 308
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,271评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,427评论 1 345
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,121评论 5 340
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,756评论 3 324
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,375评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,579评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,410评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,315评论 2 352

推荐阅读更多精彩内容