Connect to Amazon Cloud Drive from Debian Command line

amazon-cloud-drive

UPDATE: It seems Amazon has banned ACD_CLI. I contacted Amazon to see what is their suggestion. So waiting for a feedback from them now.

We are going to connect to Amazon Cloud Drive from Debian Command line to utilize the benefit of unlimited cloud storage. Even there are various tutorials out there, finding a really “workable” one is not a trivial work. I summarize some steps here for reference.

  1. First, we need to install necessary environment (softwares):
    apt-get install links #Web browser for command line
    apt-get install libsqlite3-dev #Need before build python3, since it is used in acd_cli
  2. Build python from source, remember that we need 3.5 (latest version currently):
    1. Download  and install latest python at https://www.python.org/downloads/release/python-361/:
      wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
      tar zxvf Python-3.6.1.tgz
      cd Python-3.6.1
      ./configure
      make
      make install
    2. Check to be sure Python is in the correct version
      python3 -V

      . Link it if it requires to be in /usr/bin/python3:

      ln -s /usr/local/bin/python3 /usr/bin/python3
  3. Install pip:
    wget https://bootstrap.pypa.io/get-pip.py
    python3 get-pip.py
  4. Install acdcli:
    pip3 install --upgrade --pre acdcli
  5. Init acd:
    acd_cli -v init

    . Remember that after login with Amazon account, you’ll need to grant access to the acd_cli_oa and then must have the returned JSON in the right location: /root/.cache/acd_cli/oauth_data. If you use the text-based browser, be sure to save the output JSON and move it to the proper place after permission granting. The file is sth as follows:

    {
        "access_token": "TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___TOKEN_HERE___",
        "exp_time": 1460728465.1998088,
        "expires_in": 3600,
        "refresh_token": "OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__OTHER_TOKEN_HERE__",
        "token_type": "bearer"
    }
  6. Before doing anything, we need to sync:
    acd_cli sync
  7. Access Amazon Cloud Drive from the Command Line: Basically, we'll need to mount the Amazon Cloud Drive into our Linux File System and then run rsync periodly (hourly/every 6 hours/daily/weekly) to keep data be synchronized.
    1. Mount it:
      mkdir /mnt/AmazonCloudDrive
      acd_cli mount /mnt/AmazonCloudDrive
    2. Test the mount:
      df -h
    3. Copy files/folder or Setup sync from local server to remote AWS:
      rsync -uptorgvlHaz /YOUR_BACKUP_PATH/ /mnt/AmazonCloudDrive/FOLDER_NAME/
    4. What we need to do for future synchronization is to create a cron job so that the rsync command can be run daily.

TroubleShooting

 

Leave a Reply