Giter Club home page Giter Club logo

dbx-tools's Introduction

Introduction

dbx-tools is a set of command line tools to manually keep a local directory in sync with your Dropbox.

In a production environment, use one of the releases tagged in Git. And, keep in mind: This is experimental software! Use it responsibly, especially when manipulating lots of files at once.

dbx-tools depends on dbxcli. It was tested with dbxcli Git release v2.1.1. Note that the version number in the output of dbxcli version does not match that of the Git release:

dbxcli version: 0.1.0
SDK version: 4.5.0
Spec version: a1d5111

dbx-tools was originally written for interfacing with Dropbox from within the Termux terminal emulator for Android.

Sample session

  1. Make sure that dbxcli is available and that you are logged into Dropbox:

    ~$ dbxcli account
    
  2. Create a path for your Dropbox and tell dbx-tools about it.

    ~$ mkdir Dropbox
    ~$ export DBX_HOME="$HOME/Dropbox"
    
  3. Enable dbx-cd:

    ~$ source "`which dbx-cd-source`"
    
  4. To get help on any command, use the -h option:

    ~$ dbx-ls -h
    Usage: dbx-ls […]
    
  5. Navigate your Dropbox, noticing that local paths are created if necessary:

    ~$ cd Dropbox
    ~/Dropbox$ dbx-ls
    Pictures/
    Documents/
    Info.txt
    ~/Dropbox$ dbx-cd Documents
    ~/Dropbox/Documents$ dbx-pwd
    /Documents
    
  6. Create and upload a file:

    ~/Dropbox$ echo Hello >Greeting.txt
    ~/Dropbox$ dbx-put Greeting.txt
    […]
    ~/Dropbox$ dbx-ls -l
    Revision         Size  Last modified  Path
    […]
    54913be5010b7a9a 6 B   47 seconds ago Greeting.txt
    […]
    
  7. Try to upload the same file again:

    ~/Dropbox$ dbx-put Greeting.txt
    [skipped]
    

    Files that have been previously uploaded are skipped. This functionality compares hashes of file meta data plus file content. If a file is moved, then its meta data changes, and it will be uploaded again on dbx-put.

  8. Create and upload a directory:

    ~/Dropbox$ mkdir Greetings
    ~/Dropbox$ echo Hello >Greetings/en
    ~/Dropbox$ echo Hallo >Greetings/de
    ~/Dropbox$ echo Salut >Greetings/fr
    ~/Dropbox$ echo Hola >Greetings/es
    ~/Dropbox$ dbx-put Greetings
    […]
    ~/Dropbox$ dbx-ls -R
    […]
    Greetings/
    […]
    Greetings/en
    Greetings/de
    Greetings/fr
    Greetings/es
    […]
    
  9. Download a file:

    ~/Dropbox$ dbx-get Goodbye.txt
    […]
    
  10. Try to download the same file again:

    ~/Dropbox$ dbx-get Goodbye.txt
    [skipped]
    

    Files that have been previously downloaded are skipped. This functionality compares revsions of files. Note that if a file is moved or renamed, then its revision changes, i.e. it will be downloaded again.

  11. Download a directory

    ~/Dropbox$ dbx-get Goodbyes
    […]
    
  12. Delete a file:

    ~/Dropbox$ dbx-rm Greetings.txt
    […]
    ~/Dropbox$ dbx-ls -l
    Revision         Size  Last modified  Path
    […]
    [remote file is missing]
    […]
    ~/Dropbox$ ls -l
    […]
    [local file has been deleted as well]
    […]
    
  13. Remove a directory:

    ~/Dropbox$ dbx-rm -r Greetings
    […]
    
  14. Clear hashes and revisions generated when uploading respectively downloading files:

    ~/Dropbox$ dbx-clear-cache
    […]
    

    Clearing the cache should rarely be necessary. It takes up little space, and keeping it prevents unnecessary uploads and downloads.

  15. When moving around with dbx-cd, lots of unused empty directories may be created. To clean up empty directories in $DBX_HOME, use:

    ~/Dropbox$ dbx-clean
    […]
    

Coding conventions

  • $VARIABLE_NAME

  • function-name

  • Maximum line length: 70

  • Indentation depth: 4 spaces

License

Except where noted otherwise, files are licensed under the WTFPL.

Copyright © 2018 Felix E. Klee

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.

dbx-tools's People

Contributors

feklee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

laranea

dbx-tools's Issues

dbx-cd doesn't work properly

An example:

$ dbx-ls
Sync su NAS/
Cartella del team xxx SNC/
commerciale/
Proter xxx su Dropbox/
Outlook/

$ dbx-cd commerciale

$ dbx-pwd
Current directory not in $DBX_HOME

$ echo $DBX_HOME
/home/xxx/Code/02_xxx/test/dbx-tools/xxx

$ dbx-ls
Sync su NAS/
Cartella del team xxx SNC/
commerciale/
Proter xxx su Dropbox/
Outlook/

--

I have edited this line in init.sh from:

DOT_DIR="$HOME/.dbx-tools"

to:

DOT_DIR="$HOME/Code/02_xxx/test/.dbx-tools"

I suggest you to permit to set DOT_DIR by export.

dbxcli version?

Hello. Your readme says tested with dbxcli Git release v2.1.1 but then it lists right below it dbxcli version: 0.1.0, so I'm confused. Are these tools for v2.1.1 or for 0.1.0?

dbx-get does not work for non-local (nested?) folders

I've been trying to do some selective bulk downloads for a specific filetype (ie: download all JPG files in folders of RAW+JPG files), and I ended up doing something like with

# Pull DBX file list.
dbxcli ls -Rl /photography/ > ~/dbx_files.log

# Filter for all JPGs JPGs, and transform the text to just be the path with quotes.
cat ~/ls_output.log | grep '.JPG' | cut -c 55- | awk '{$1=$1;print}' | sed 's/^/"/;s/$/"/' > ~/dbx_jpg_files.log

# Grab all files
cat ~/dbx_jpg_files.log | xargs -n 1 ~/dbx-tools/dbx-get

Unfortunately dbx-get ends up failing if the files are part of a subfolder (eg: /photography/trip1) that is not yet created locally (ie: have not done dbx-cd /photography/trip1). To get it to work, I needed to first dbx-cd all of the folders -- which was quite a lot!

I think this may have been a bit more nuanced too, it only failed if there was an inner folder (eg: /photography/trip1/location1) while the outer folder (trip1) was uninitialized. I'll have to do a bit more testing to figure out when/how it didn't work.

I suspect the right thing to do in these situations is to initialize the folders eagerly here. I'll see if I can get a patch up for this too (:

Thanks a ton for this tool btw, it was very helpful for managing files and just worked (:

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.