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):

    [bash]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[/bash]

  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/:

      [bash]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[/bash]

    2. Check to be sure Python is in the correct version

      [bash]python3 -V[/bash]

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

      [bash]ln -s /usr/local/bin/python3 /usr/bin/python3[/bash]

  3. Install pip:

    [bash]wget https://bootstrap.pypa.io/get-pip.py
    python3 get-pip.py[/bash]

  4. Install acdcli:

    [bash]pip3 install –upgrade –pre acdcli[/bash]

  5. Init acd:

    [bash]acd_cli -v init[/bash]

    . 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:

    [javascript]{
    "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"
    }[/javascript]

  6. Before doing anything, we need to sync:
    [bash]acd_cli sync[/bash]

  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:

      [bash]mkdir /mnt/AmazonCloudDrive
      acd_cli mount /mnt/AmazonCloudDrive[/bash]

    2. Test the mount:

      [bash]df -h[/bash]

    3. Copy files/folder or Setup sync from local server to remote AWS:

      [bash]rsync -uptorgvlHaz /YOUR_BACKUP_PATH/ /mnt/AmazonCloudDrive/FOLDER_NAME/[/bash]

    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 comment

Your email address will not be published. Required fields are marked *