저는 Amazon Cloud Drive를 사용하여 사진 2차 백업을 하고 있습니다. 제가 가진 각 장비(모바일, 태블릿, 디지털카메라 등)에서 찍은 사진들을 집에 구축된 NAS에 모아놓고 있었는데, ESXi 를 이용한 가상화 환경 + HDD에 대한 약간의 불신 등으로 2차 백업이 필요해보이더라구요. 프로그래머 답게 자동화 할 수 있는 방법을 찾았는데 예전에는 acd_cli를 사용하고 있었는데 설치가 어려웠고, 집에 리눅스 박스를 재정비하면서 새로운 것을 찾던 중에 rclone을 발견하게 되었습니다.

설치법이 가이드 되어 있는 대로 설치를 하고 나면 제일 처음 해야 할 일은 환경 설정입니다.

$ rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q>

새로 추가하기 위해 n을 타입하면 이름과 동기화할 클라우드 스토리지 서비스를 선택할 수 있습니다.

n/s/q> n
name> acd
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Amazon Drive
   \ "amazon cloud drive"
 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
   \ "s3"
 3 / Backblaze B2
   \ "b2"
 4 / Dropbox
   \ "dropbox"
 5 / Encrypt/Decrypt a remote
   \ "crypt"
 6 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
 7 / Google Drive
   \ "drive"
 8 / Hubic
   \ "hubic"
 9 / Local Disk
   \ "local"
10 / Microsoft OneDrive
   \ "onedrive"
11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
12 / Yandex Disk
   \ "yandex"
Storage>

세부 설정인데, 잘 모르면 Enter만 쳐도 괜찮다고 하네요.

Storage> 1
Amazon Application Client Id - leave blank normally.
client_id>
Amazon Application Client Secret - leave blank normally.
client_secret>
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...

위에 나온 주소를 웹브라우저로 열면 Amazon OAuth 창이 열려 rclone 웹앱에 대한 권한 획득 페이지가 나옵니다. 허용을 하게 되면 rclone이 이를 캐치하여 다음으로 진행되게 됩니다. (로컬IP=127.0.0.1로만 접근이 됩니다. 다른 컴퓨터에서 접근이 불가하더라구요. 아마도 bind=127.0.0.1식으로 구현되어 있는 것 같습니다. 따라서 저는 Ubuntu server 버전을 설치하여 elinks와 같은 텍스트 웹브라우저를 사용하여 접근하였습니다.)

Waiting for code...
Got code
--------------------
[acd]
client_id =
client_secret =
token = {"access_token":"SECURED ACCESS TOKEN IN HERE","token_type":"bearer","refresh_token":"SECURED REFRESH TOKEN IN HERE","expiry":"2016-09-06T23:04:13.496719067+09:00"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name Type
==== ====
acd amazon cloud drive

e) Edit existing remote
n) New remote
d) Delete remote
s) Set configuration password
q) Quit config
e/n/d/s/q>

이제 설정은 끝났으니 잘 되나 봅니다.

$ rclone ls acd:/
...
  5543877 Mobile Photos/20160404_115526.jpg
  5413241 Mobile Photos/20160404_115552.jpg
...
2016/09/06 22:07:16
Transferred:      0 Bytes (0 Bytes/s)
Errors:                 0
Checks:                 0
Transferred:            0
Elapsed time:        9.1s

잘 접근이 되면 사용법과 같이 간단하게 동기화를 실행할 수 있습니다.

rclone sync source:path dest:path

$ rclone sync /mnt/nas-photo/ acd:/
2016/09/06 22:32:52
Transferred:   127.256 MBytes (2.041 MBytes/s)
Errors:                 0
Checks:              1952
Transferred:           31
Elapsed time:      1m2.3s
Transferring:
 *             Mobile Photos/20160603_203700.jpg: 100% done. avg:   58.1, cur:  181.2 kByte/s. ETA: 0s
 *         Mobile Photos/IMG_20160819_193057.jpg: 100% done. avg:   11.7, cur:   48.5 kByte/s. ETA: 0s
 *        Mobile Photos/B612_20160606_183804.jpg: 100% done. avg:   19.3, cur:   52.4 kByte/s. ETA: 0s
 * ...le Photos/C360_2016-05-28-19-28-12-730.jpg: 100% done. avg:  473.2, cur:  371.4 kByte/s. ETA: 0s

로컬 리소스는 source, dest 등의 namespace를 지정하지 않고 사용하면 되는 듯 합니다. 🙂